From 9866701aefe22811498fedff1e90f86e736f82be Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 22 Apr 2026 16:12:33 -0500 Subject: [PATCH 1/4] [Build] Add Inputs/Outputs to _GenerateCompressedAssembliesNativeSourceFiles Add Inputs/Outputs to the _GenerateCompressedAssembliesNativeSourceFiles target so it is skipped on incremental builds when no assemblies have changed. This saves ~143ms on every no-change rebuild. - Inputs: @(_ResolvedUserAssemblies);@(_ResolvedFrameworkAssemblies) - Outputs: @(_CompressedAssembliesAssemblySource) (the .ll files) Also update BasicApplicationRepetitiveBuild to assert the target is skipped on a no-change rebuild. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs | 1 + .../Xamarin.Android.Common.targets | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) 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 8e3600f20dd..7d6da539677 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 @@ -41,6 +41,7 @@ public void BasicApplicationRepetitiveBuild ([Values] AndroidRuntime runtime) Assert.IsTrue ( b.Output.IsTargetSkipped ("_Sign"), "the _Sign target should not run"); + b.Output.AssertTargetIsSkipped ("_GenerateCompressedAssembliesNativeSourceFiles"); var item = proj.AndroidResources.First (x => x.Include () == "Resources\\values\\Strings.xml"); item.TextContent = () => proj.StringsXml.Replace ("${PROJECT_NAME}", "Foo"); item.Timestamp = null; diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 1f37f9198bc..2765c1b9e17 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -1997,7 +1997,9 @@ because xbuild doesn't support framework reference assemblies. + Condition=" '$(_AndroidRuntime)' != 'NativeAOT' " + Inputs="@(_ResolvedUserAssemblies);@(_ResolvedFrameworkAssemblies)" + Outputs="@(_CompressedAssembliesAssemblySource)"> Date: Wed, 22 Apr 2026 16:14:58 -0500 Subject: [PATCH 2/4] Add build.props as Input to _GenerateCompressedAssembliesNativeSourceFiles Include $(_AndroidBuildPropertiesCache) (build.props) so that changes to build properties like Debug or EnableCompression also trigger a rebuild. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 2765c1b9e17..5304e2d1691 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -1998,7 +1998,7 @@ because xbuild doesn't support framework reference assemblies. Date: Wed, 22 Apr 2026 16:17:51 -0500 Subject: [PATCH 3/4] Touch output files so Inputs/Outputs comparison works correctly The task uses Files.CopyIfStreamChanged which preserves the old timestamp when content is unchanged. Without Touch, MSBuild would always see inputs newer than outputs and re-run the target. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 5304e2d1691..c51b54d51ca 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -2008,6 +2008,7 @@ because xbuild doesn't support framework reference assemblies. EnableCompression="$(AndroidEnableAssemblyCompression)" ProjectFullPath="$(MSBuildProjectFullPath)" /> + From 3f0efb0afc37e10d4454c6be6612710bd9bd9c3f Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 22 Apr 2026 16:42:55 -0500 Subject: [PATCH 4/4] Add AndroidEnableAssemblyCompression to _PropertyCacheItems The compressed assemblies task uses EnableCompression to change its output, so toggling this property must invalidate build.props to trigger a rebuild. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index c51b54d51ca..c5bc61d16c2 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -988,6 +988,7 @@ because xbuild doesn't support framework reference assemblies. <_PropertyCacheItems Include="_NuGetAssetsFileHash=%(_NuGetAssetsFileHash.FileHash)" /> <_PropertyCacheItems Include="AndroidManifestPlaceholders=$(AndroidManifestPlaceholders)" /> <_PropertyCacheItems Include="ProjectFullPath=$(MSBuildProjectFullPath)" /> + <_PropertyCacheItems Include="AndroidEnableAssemblyCompression=$(AndroidEnableAssemblyCompression)" /> <_PropertyCacheItems Include="AndroidUseDesignerAssembly=$(AndroidUseDesignerAssembly)" /> <_PropertyCacheItems Include="_AndroidTypeMapImplementation=$(_AndroidTypeMapImplementation)" />