From 365cb18d1894700f1dd79116af9b3c0e60a4f9cc Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 16 Jun 2025 11:22:42 -0500 Subject: [PATCH] [xabt] remove `$(AndroidStripILAfterAOT)` Fixes: https://github.com/dotnet/android/issues/9577 Partially reverts 82a40927. We introduced an "experimental" property `$(AndroidStripILAfterAOT)` in .NET 8, which has a few flaws as mentioned in #9577. I've seen this come up on a couple customer issues, and the solution was to stop using the feature... Since, this feature is only available for Mono (not CoreCLR or NativeAOT), it feels like we should remove it from the codebase for now. We could bring it back in the future, if we also solved #9577. --- .../building-apps/build-properties.md | 2 +- .../targets/Microsoft.Android.Sdk.Aot.targets | 38 +------------------ ...soft.Android.Sdk.DefaultProperties.targets | 2 +- .../Xamarin.Android.Common.targets | 2 +- .../Tests/InstallAndRunTests.cs | 38 ------------------- 5 files changed, 4 insertions(+), 78 deletions(-) diff --git a/Documentation/docs-mobile/building-apps/build-properties.md b/Documentation/docs-mobile/building-apps/build-properties.md index 41efdfafdae..7d41ce429f7 100644 --- a/Documentation/docs-mobile/building-apps/build-properties.md +++ b/Documentation/docs-mobile/building-apps/build-properties.md @@ -1245,7 +1245,7 @@ This means that in Release configuration builds -- in which This can result in increased app sizes. This behavior can be overridden by explicitly setting `$(AndroidEnableProfiledAot)` to `true` within your project file. -Support for this property was added in .NET 8. +Experimental support for this property was added in .NET 8, removed in .NET 10. ## AndroidSupportedAbis diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets index 17d7009cc86..d80be84d01c 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets @@ -137,50 +137,14 @@ They run in a context of an inner build with a single $(RuntimeIdentifier). LLVMPath="$(_LLVMPath)" LdName="$(_LdName)" LdFlags="$(_LdFlags)" - CollectTrimmingEligibleMethods="$(AndroidStripILAfterAOT)" + CollectTrimmingEligibleMethods="$(_AndroidCollectTrimmingEligibleMethods)" TrimmingEligibleMethodsOutputDirectory="$(IntermediateOutputPath)tokens" WorkingDirectory="$(MSBuildProjectDirectory)" AotArguments="$(AndroidAotAdditionalArguments)"> - - - - - - <_UpdateStamp Include="@(_ILStripUpdatedAssemblies)" Condition=" '$(AndroidStripILAfterAOT)' == 'true' and '%(_ILStripUpdatedAssemblies.ILStripped)' == 'true' " /> - - - - - <_StampDir>$(_AndroidStampDirectory)\..\..\stamp - - - true <_AndroidXA1030 Condition=" '$(RunAOTCompilation)' == 'true' and '$(PublishTrimmed)' == 'false' ">true $(RunAOTCompilation) - true + true diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index d179740e994..d4e1cb54878 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -1087,44 +1087,6 @@ public void FastDeployEnvironmentFiles (bool isRelease, bool embedAssembliesInto } } - [Test] - public void EnableAndroidStripILAfterAOT ([Values (false, true)] bool profiledAOT) - { - var proj = new XamarinAndroidApplicationProject { - ProjectName = nameof (EnableAndroidStripILAfterAOT), - RootNamespace = nameof (EnableAndroidStripILAfterAOT), - IsRelease = true, - EnableDefaultItems = true, - }; - proj.SetProperty("AndroidStripILAfterAOT", "true"); - proj.SetProperty("AndroidEnableProfiledAot", profiledAOT.ToString ()); - // So we can use Mono.Cecil to open assemblies directly - proj.SetProperty ("AndroidEnableAssemblyCompression", "false"); - - var builder = CreateApkBuilder (); - Assert.IsTrue (builder.Build (proj), "`dotnet build` should succeed"); - - var apk = Path.Combine (Root, builder.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - FileAssert.Exists (apk); - var helper = new ArchiveAssemblyHelper (apk); - Assert.IsTrue (helper.Exists ($"assemblies/{proj.ProjectName}.dll"), $"{proj.ProjectName}.dll should exist in apk!"); - using (var stream = helper.ReadEntry ($"assemblies/{proj.ProjectName}.dll")) { - stream.Position = 0; - using var assembly = AssemblyDefinition.ReadAssembly (stream); - var type = assembly.MainModule.GetType ($"{proj.RootNamespace}.MainActivity"); - var method = type.Methods.FirstOrDefault (p => p.Name == "OnCreate"); - Assert.IsNotNull (method, $"{proj.RootNamespace}.MainActivity.OnCreate should exist!"); - Assert.IsTrue (!method.HasBody || method.Body.Instructions.Count == 0, $"{proj.RootNamespace}.MainActivity.OnCreate should have no body!"); - } - - RunProjectAndAssert (proj, builder); - - WaitForPermissionActivity (Path.Combine (Root, builder.ProjectDirectory, "permission-logcat.log")); - bool didLaunch = WaitForActivityToStart (proj.PackageName, "MainActivity", - Path.Combine (Root, builder.ProjectDirectory, "logcat.log"), 30); - Assert.IsTrue(didLaunch, "Activity should have started."); - } - [Test] public void FixLegacyResourceDesignerStep ([Values (true, false)] bool isRelease) {