diff --git a/external/Java.Interop b/external/Java.Interop
index 60e85b0424c..8ed96776e41 160000
--- a/external/Java.Interop
+++ b/external/Java.Interop
@@ -1 +1 @@
-Subproject commit 60e85b0424c1cf706ac8c5f1e6ff6e84d38cf3b5
+Subproject commit 8ed96776e41040209ebca26e99df1f8b522ae0b2
diff --git a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/Linker.cs b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/Linker.cs
index 7735fdf5c8d..4874d876cd9 100644
--- a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/Linker.cs
+++ b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/Linker.cs
@@ -62,7 +62,7 @@ static Pipeline CreatePipeline (LinkerOptions options)
if (options.LinkNone) {
pipeline.AppendStep (new FixAbstractMethodsStep ());
- pipeline.AppendStep (new OutputStep ());
+ pipeline.AppendStep (new OutputStepWithTimestamps ());
return pipeline;
}
@@ -117,7 +117,7 @@ static Pipeline CreatePipeline (LinkerOptions options)
pipeline.AppendStep (new StripEmbeddedLibraries ());
// end monodroid specific
pipeline.AppendStep (new RegenerateGuidStep ());
- pipeline.AppendStep (new OutputStep ());
+ pipeline.AppendStep (new OutputStepWithTimestamps ());
return pipeline;
}
diff --git a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/OutputStepWithTimestamps.cs b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/OutputStepWithTimestamps.cs
new file mode 100644
index 00000000000..b4e9c93608b
--- /dev/null
+++ b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/OutputStepWithTimestamps.cs
@@ -0,0 +1,50 @@
+using System.IO;
+using Mono.Cecil;
+using Mono.Cecil.Cil;
+using Mono.Linker.Steps;
+using Xamarin.Android.Tools;
+
+namespace MonoDroid.Tuner
+{
+ ///
+ /// A subclass of OutputStep that overrides CopyAssembly and timestamps files properly with Files.CopyIfChanged
+ /// * original source from: https://github.com/mono/linker/blob/aa65acca5e41fbc1f8f597799381b853049704ff/src/linker/Linker.Steps/OutputStep.cs#L198-L231
+ ///
+ class OutputStepWithTimestamps : OutputStep
+ {
+ static FileInfo GetOriginalAssemblyFileInfo (AssemblyDefinition assembly)
+ {
+ return new FileInfo (assembly.MainModule.FileName);
+ }
+
+ protected override void CopyAssembly (AssemblyDefinition assembly, string directory)
+ {
+ // Special case. When an assembly has embedded pdbs, link symbols is not enabled, and the assembly's action is copy,
+ // we want to match the behavior of assemblies with the other symbol types and end up with an assembly that does not have symbols.
+ // In order to do that, we can't simply copy files. We need to write the assembly without symbols
+ if (assembly.MainModule.HasSymbols && !Context.LinkSymbols && assembly.MainModule.SymbolReader is EmbeddedPortablePdbReader) {
+ WriteAssembly (assembly, directory, new WriterParameters ());
+ return;
+ }
+
+ FileInfo fi = GetOriginalAssemblyFileInfo (assembly);
+ string target = Path.GetFullPath (Path.Combine (directory, fi.Name));
+ string source = fi.FullName;
+ if (source == target)
+ return;
+
+ Files.CopyIfChanged (source, target);
+
+ if (!Context.LinkSymbols)
+ return;
+
+ var mdb = source + ".mdb";
+ if (File.Exists (mdb))
+ Files.CopyIfChanged (mdb, target + ".mdb");
+
+ var pdb = Path.ChangeExtension (source, "pdb");
+ if (File.Exists (pdb))
+ Files.CopyIfChanged (pdb, Path.ChangeExtension (target, "pdb"));
+ }
+ }
+}
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs
index dbcdb955d0e..ec045b62ee6 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs
@@ -504,11 +504,9 @@ public void CheckTimestamps ([Values (true, false)] bool isRelease)
// Xamarin.Android unless fastdev is enabled.
foreach (var file in new [] { "typemap.mj", "typemap.jm" }) {
var info = new FileInfo (Path.Combine (intermediate, "android", file));
- if (!info.Exists) {
- Assert.Ignore ($"{info.Name} does not exist, timestamp check skipped");
- continue;
+ if (info.Exists) {
+ Assert.IsTrue (info.LastWriteTimeUtc > start, $"`{file}` is older than `{start}`, with a timestamp of `{info.LastWriteTimeUtc}`!");
}
- Assert.IsTrue (info.LastWriteTimeUtc > start, $"`{file}` is older than `{start}`, with a timestamp of `{info.LastWriteTimeUtc}`!");
}
//One last build with no changes
@@ -1187,12 +1185,6 @@ public void BuildBasicApplicationCheckMdbRepeatBuild ()
File.Exists (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android/assets/UnnamedProject.pdb")),
"UnnamedProject.dll.mdb must be copied to the Intermediate directory");
Assert.IsTrue (b.Build (proj), "second build failed");
- Assert.IsTrue (
- b.Output.IsTargetSkipped ("_CopyMdbFiles"),
- "the _CopyMdbFiles target should be skipped");
- Assert.IsTrue (
- b.Output.IsTargetSkipped ("_CopyPdbFiles"),
- "the _CopyPdbFiles target should be skipped");
Assert.IsTrue (
File.Exists (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android/assets/UnnamedProject.dll.mdb")) ||
File.Exists (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android/assets/UnnamedProject.pdb")),
@@ -1252,9 +1244,11 @@ public Class2 ()
Assert.IsTrue (libb.Build (lib), "Library1 Build should have succeeded.");
using (var b = CreateApkBuilder (Path.Combine (path, "App1"))) {
Assert.IsTrue (b.Build (proj), "App1 Build should have succeeded.");
- var assetsPdb = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "assets", "Library1.pdb");
- var linkDst = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "linkdst", "Library1.pdb");
- var linkSrc = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "linksrc", "Library1.pdb");
+ var intermediate = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath);
+ var outputPath = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath);
+ var assetsPdb = Path.Combine (intermediate, "android", "assets", "Library1.pdb");
+ var linkDst = Path.Combine (intermediate, "linkdst", "Library1.pdb");
+ var binSrc = Path.Combine (outputPath, "Library1.pdb");
Assert.IsTrue (
File.Exists (assetsPdb),
"Library1.pdb must be copied to Intermediate directory");
@@ -1262,29 +1256,27 @@ public Class2 ()
File.Exists (linkDst),
"Library1.pdb should not be copied to linkdst directory because it has no Abstrsact methods to fix up.");
Assert.IsTrue (
- File.Exists (linkSrc),
- "Library1.pdb must be copied to linksrc directory");
- var outputPath = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath);
+ File.Exists (binSrc),
+ "Library1.pdb must be copied to bin directory");
using (var apk = ZipHelper.OpenZip (Path.Combine (outputPath, proj.PackageName + "-Signed.apk"))) {
var data = ZipHelper.ReadFileFromZip (apk, "assemblies/Library1.pdb");
if (data == null)
data = File.ReadAllBytes (assetsPdb);
- var filedata = File.ReadAllBytes (linkSrc);
- Assert.AreEqual (filedata.Length, data.Length, "Library1.pdb in the apk should match {0}", linkSrc);
+ var filedata = File.ReadAllBytes (binSrc);
+ Assert.AreEqual (filedata.Length, data.Length, "Library1.pdb in the apk should match {0}", binSrc);
}
- linkDst = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "linkdst", "App1.pdb");
- linkSrc = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "linksrc", "App1.pdb");
+ linkDst = Path.Combine (intermediate, "linkdst", "App1.pdb");
+ binSrc = Path.Combine (outputPath, "App1.pdb");
Assert.IsTrue (
File.Exists (linkDst),
"App1.pdb should be copied to linkdst directory because it has Abstrsact methods to fix up.");
Assert.IsTrue (
- File.Exists (linkSrc),
- "App1.pdb must be copied to linksrc directory");
- FileAssert.AreEqual (linkSrc, linkDst, "{0} and {1} should not differ.", linkSrc, linkDst);
- linkDst = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "linkdst", "App1.dll");
- linkSrc = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "linksrc", "App1.dll");
- FileAssert.AreEqual (linkSrc, linkDst, "{0} and {1} should match.", linkSrc, linkDst);
-
+ File.Exists (binSrc),
+ "App1.pdb must be copied to bin directory");
+ FileAssert.AreEqual (binSrc, linkDst, "{0} and {1} should not differ.", binSrc, linkDst);
+ linkDst = Path.Combine (intermediate, "linkdst", "App1.dll");
+ binSrc = Path.Combine (outputPath, "App1.dll");
+ FileAssert.AreEqual (binSrc, linkDst, "{0} and {1} should match.", binSrc, linkDst);
}
}
}
@@ -1333,15 +1325,9 @@ public void BuildBasicApplicationCheckMdbAndPortablePdb ()
File.Exists (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "assets", "NetStandard16.pdb")),
"NetStandard16.pdb must be copied to Intermediate directory");
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "second build failed");
- Assert.IsTrue (
- b.Output.IsTargetSkipped ("_CopyMdbFiles"),
- "the _CopyMdbFiles target should be skipped");
var lastTime = File.GetLastWriteTimeUtc (pdbToMdbPath);
pdb.Timestamp = DateTimeOffset.UtcNow;
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "third build failed");
- Assert.IsFalse (
- b.Output.IsTargetSkipped ("_CopyMdbFiles"),
- "the _CopyMdbFiles target should not be skipped");
Assert.Less (lastTime,
File.GetLastWriteTimeUtc (pdbToMdbPath),
"{0} should have been updated", pdbToMdbPath);
@@ -2855,16 +2841,10 @@ public void BuildBasicApplicationCheckPdb ()
}
b.BuildLogFile = "build1.log";
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "second build failed");
- Assert.IsTrue (
- b.Output.IsTargetSkipped ("_CopyMdbFiles"),
- "the _CopyMdbFiles target should be skipped");
b.BuildLogFile = "build2.log";
var lastTime = File.GetLastWriteTimeUtc (pdbToMdbPath);
pdb.Timestamp = DateTimeOffset.UtcNow;
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "third build failed");
- Assert.IsFalse (
- b.Output.IsTargetSkipped ("_CopyMdbFiles"),
- "the _CopyMdbFiles target should not be skipped");
Assert.Less (lastTime,
File.GetLastWriteTimeUtc (pdbToMdbPath),
"{0} should have been updated", pdbToMdbPath);
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs
index 92d3b680e7b..e6d0d8d62e7 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs
@@ -345,13 +345,11 @@ public Class2 ()
public void AppProjectTargetsDoNotBreak ()
{
var targets = new List {
- "_CopyIntermediateAssemblies",
"_GeneratePackageManagerJava",
"_ResolveLibraryProjectImports",
"_BuildAdditionalResourcesCache",
"_CleanIntermediateIfNuGetsChange",
"_CopyConfigFiles",
- "_CopyPdbFiles",
};
var proj = new XamarinFormsAndroidApplicationProject {
OtherBuildItems = {
@@ -366,7 +364,6 @@ public void AppProjectTargetsDoNotBreak ()
if (IsWindows) {
//NOTE: pdb2mdb will run on Windows on the current project's symbols if DebugType=Full
proj.SetProperty (proj.DebugProperties, "DebugType", "Full");
- targets.Add ("_CopyMdbFiles");
targets.Add ("_ConvertPdbFiles");
}
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs
index 225b3038cde..4ece2ab17ed 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs
@@ -66,8 +66,7 @@ public void CheckBuildIdIsUnique ()
var allFilesInArchive = Directory.GetFiles (archivePath, "*", SearchOption.AllDirectories);
string extension = "dll";
Assert.IsTrue (allFilesInArchive.Any (x => Path.GetFileName (x) == $"{proj.ProjectName}.{extension}"), $"{proj.ProjectName}.{extension} should exist in {archivePath}");
- //NOTE: Windows is still generating mdb files here
- extension = IsWindows ? "dll.mdb" : "pdb";
+ extension = "pdb";
Assert.IsTrue (allFilesInArchive.Any (x => Path.GetFileName (x) == $"{proj.ProjectName}.{extension}"), $"{proj.ProjectName}.{extension} should exist in {archivePath}");
string intermediateOutputDir = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath);
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj
index f0ae0d61ef8..b2a6dd6dcfc 100644
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj
@@ -127,6 +127,7 @@
+
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
index a8ee8837bc6..5cc3e8823ff 100755
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
@@ -1192,8 +1192,8 @@ because xbuild doesn't support framework reference assemblies.
$(IntermediateOutputPath)res\
$(IntermediateOutputPath)android\assets\
- $(IntermediateOutputPath)linksrc\
$(IntermediateOutputPath)android\assets\
+ <_JniMarshalMethodsOutputDir>$(IntermediateOutputPath)jnisrc\
$(IntermediateOutputPath)linkdst\
Resources
$(IntermediateOutputPath)
@@ -1202,7 +1202,6 @@ because xbuild doesn't support framework reference assemblies.
<_AndroidAotBinDirectory>$(IntermediateOutputPath)aot
<_AndroidResgenFlagFile>$(IntermediateOutputPath)R.cs.flag
<_AndroidResFlagFile>$(IntermediateOutputPath)res.flag
- <_AndroidJniMarshalMethodsFlag>$(IntermediateOutputPath)jnimarshalmethods.flag
<_AndroidLinkFlag>$(IntermediateOutputPath)link.flag
<_AndroidApkPerAbiFlagFile>$(IntermediateOutputPath)android\bin\apk_per_abi.flag
<_AndroidDebugKeyStoreFlag>$(IntermediateOutputPath)android_debug_keystore.flag
@@ -1249,6 +1248,7 @@ because xbuild doesn't support framework reference assemblies.
<_PropertyCacheItems Include="AndroidUseLatestPlatformSdk=$(AndroidUseLatestPlatformSdk)" />
<_PropertyCacheItems Include="TargetFrameworkVersion=$(TargetFrameworkVersion)" />
<_PropertyCacheItems Include="AndroidCreatePackagePerAbi=$(AndroidCreatePackagePerAbi)" />
+ <_PropertyCacheItems Include="AndroidGenerateJniMarshalMethods=$(AndroidGenerateJniMarshalMethods)" />
<_PropertyCacheItems Include="OS=$(OS)" />
<_PropertyCacheItems Include="DesignTimeBuild=$(DesignTimeBuild)" />
<_PropertyCacheItems Include="AndroidIncludeDebugSymbols=$(AndroidIncludeDebugSymbols)" />
@@ -1947,25 +1947,6 @@ because xbuild doesn't support framework reference assemblies.
-
-
- <_CIAResolvedAssembliesDestinationFiles Include="@(ResolvedAssemblies->'$(MonoAndroidLinkerInputDir)%(Filename)%(Extension)')" />
- <_CIAResolvedSatellitePathsDestinationFiles Include="@(_AndroidResolvedSatellitePaths->'$(MonoAndroidLinkerInputDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
-
-
-
-
-
-
-
-
-
-
-
-
@@ -2016,56 +1997,31 @@ because xbuild doesn't support framework reference assemblies.
-
-
- <_CopyPdbFilesLinkerFiles Include="@(_ResolvedPortablePdbFiles->'$(MonoAndroidLinkerInputDir)%(Filename)%(Extension)')" />
-
-
-
-
-
-
-
-
-
-
- <_CopyMdbFilesLinkerFiles Include="@(_ResolvedMdbFiles->'$(MonoAndroidLinkerInputDir)%(Filename)%(Extension)')" />
-
-
-
-
-
-
-
-
+ Inputs="$(_AndroidBuildPropertiesCache);@(ResolvedUserAssemblies)"
+ Outputs="$(_AndroidStampDirectory)_GenerateJniMarshalMethods.stamp">
<_JniFrameworkAssembly Include="Mono.Android.dll" />
<_JniFrameworkAssembly Include="OpenTK-1.0.dll" />
<_JniFrameworkAssembly Include="OpenTK.dll" />
<_JniFrameworkAssembly Include="Xamarin.Android.NUnitLite.dll" />
-
-
<_AssembliesToProcess Include="@(ResolvedUserAssemblies)" />
- <_AssembliesToProcess Include="@(ResolvedAssemblies)" Condition=" '%(Filename)' != '' And '@(_JniFrameworkAssembly)' != '' " />
+ <_AssembliesToProcess Include="@(ResolvedFrameworkAssemblies)" Condition=" '%(Filename)' == '@(_JniFrameworkAssembly->'%(Filename)')' " />
+
+
-
+
+
+
+
+
+ <_MainAssembly Condition=" '$(AndroidGenerateJniMarshalMethods)' != 'True' ">$(TargetPath)
+ <_MainAssembly Condition=" '$(AndroidGenerateJniMarshalMethods)' == 'True' ">$(_JniMarshalMethodsOutputDir)$(TargetFileName)
+
+
+ <_AssembliesToLink Include="@(ResolvedAssemblies)" />
+
+
+ <_JniAssembliesToLink Include="@(ResolvedAssemblies->'$(_JniMarshalMethodsOutputDir)%(Filename)%(Extension)')" />
+ <_AssembliesToLink Condition="Exists(%(Identity))" Include="@(_JniAssembliesToLink)" />
+ <_AssembliesToLink Condition="!Exists(@(JniAssembliesToLink))" Include="@(ResolvedAssemblies)" />
+
+
@@ -2108,7 +2077,7 @@ because xbuild doesn't support framework reference assemblies.
@@ -2136,9 +2105,8 @@ because xbuild doesn't support framework reference assemblies.
;_CheckForObsoleteAssemblies
;_ResolveSatellitePaths
;_CreatePackageWorkspace
- ;_CopyIntermediateAssemblies
- ;_CopyPdbFiles
- ;_CopyMdbFiles
+ ;_CopyConfigFiles
+ ;_ConvertPdbFiles
;_LinkAssemblies
@@ -2368,7 +2336,7 @@ because xbuild doesn't support framework reference assemblies.
-