From 3e18d5ad791337c108fae77ffc05fd18be6d1770 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 18 Nov 2019 12:01:06 -0600 Subject: [PATCH] [Xamarin.Android.Build.Tasks] remove the android\assets\shrunk directory Context: https://github.com/xamarin/xamarin-android/pull/3753 Context: https://github.com/xamarin/monodroid/pull/1053 There appears to be an issue with mono:2019-10 when the Xamarin.Forms integration project is built with AOT in `Release` mode. The issue somehow stems from two `Mono.Android.dll` existing: * `obj\Debug\android\assets\Mono.Android.dll` * `obj\Debug\android\assets\shrunk\Mono.Android.dll` Looking at how AOT is invoked, it seems like either `Mono.Android.dll` could be picked up by the parameters being passed in. We might be AOT'ing a user's `Foo.dll`, and both directories are in `$MONO_PATH` or passed via other arguments. How would we know which is picked up? The `shrunk` directory is used by the `` MSBuild task that: * Runs after the linker & `` * Removes all the `[RegisterAttribute]` from types, to further shrink `Mono.Android.dll`. It looks like we copy all `@(_ResolvedFrameworkAssemblies)` to the `shrunk` directory and fix up item groups. Why don't we just get rid of this `shrunk` directory and not copy anything? We can edit `Mono.Android.dll` in place, and incremental builds should be fine due to the use of stamp files. I also moved the flag file to: $(_AndroidStampDirectory)_RemoveRegisterAttribute.stamp To match our new MSBuild conventions. There is also usage of `@(_ShrunkFrameworkAssemblies)` that needs to be updated in monodroid. --- .external | 2 +- .../Tasks/RemoveRegisterAttribute.cs | 4 +- .../Xamarin.Android.Common.targets | 41 ++++--------------- 3 files changed, 11 insertions(+), 36 deletions(-) diff --git a/.external b/.external index 397ac19bcd2..86b518ad25d 100644 --- a/.external +++ b/.external @@ -1,2 +1,2 @@ -xamarin/monodroid:master@1b907d680cc6561dcfaddc6f997d2f6ff5456644 +xamarin/monodroid:shrunkframeworkassemblies@326b7fc28ebfc0e630e3383ea5061a3337efe986 mono/mono:2019-08@8946e49a974ea8b75fe5b8b7e93ffd4571521a85 diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/RemoveRegisterAttribute.cs b/src/Xamarin.Android.Build.Tasks/Tasks/RemoveRegisterAttribute.cs index e2883f77e7c..f98c96abd28 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/RemoveRegisterAttribute.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/RemoveRegisterAttribute.cs @@ -17,14 +17,14 @@ public class RemoveRegisterAttribute : AndroidTask const string RegisterAttribute = "Android.Runtime.RegisterAttribute"; [Required] - public ITaskItem[] ShrunkFrameworkAssemblies { get; set; } + public ITaskItem[] FrameworkAssemblies { get; set; } public bool Deterministic { get; set; } public override bool RunTask () { // Find Mono.Android.dll - var mono_android = ShrunkFrameworkAssemblies.First (f => Path.GetFileNameWithoutExtension (f.ItemSpec) == "Mono.Android").ItemSpec; + var mono_android = FrameworkAssemblies.First (f => Path.GetFileNameWithoutExtension (f.ItemSpec) == "Mono.Android").ItemSpec; var writerParameters = new WriterParameters { DeterministicMvid = Deterministic, }; diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index d8d84ba676d..759d23d0808 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -1158,7 +1158,6 @@ because xbuild doesn't support framework reference assemblies. <_AndroidLinkFlag>$(IntermediateOutputPath)link.flag <_AndroidApkPerAbiFlagFile>$(IntermediateOutputPath)android\bin\apk_per_abi.flag <_AndroidDebugKeyStoreFlag>$(IntermediateOutputPath)android_debug_keystore.flag - <_RemoveRegisterFlag>$(MonoAndroidIntermediateAssemblyDir)shrunk\shrunk.flag <_AcwMapFile>$(IntermediateOutputPath)acw-map.txt <_CustomViewMapFile>$(IntermediateOutputPath)customview-map.txt <_AndroidTypeMappingJavaToManaged>$(IntermediateOutputPath)android\typemap.jm @@ -2041,18 +2040,6 @@ because xbuild doesn't support framework reference assemblies. - - - - - - - - @@ -2516,27 +2503,16 @@ because xbuild doesn't support framework reference assemblies. - - - - - + FrameworkAssemblies="@(_ResolvedFrameworkAssemblies)" /> - - + $(MSBuildAllProjects) ;$(_PackagedResources) - ;@(_ResolvedUserAssemblies) - ;@(_ShrunkFrameworkAssemblies) + ;@(_ResolvedAssemblies) ;@(AndroidNativeLibrary) ;@(_DexFile) ;$(_AndroidBuildPropertiesCache) @@ -2717,7 +2692,7 @@ because xbuild doesn't support framework reference assemblies. AndroidSequencePointsMode="$(_SequencePointsMode)" AotAdditionalArguments="$(AndroidAotAdditionalArguments)" ExtraAotOptions="$(AndroidExtraAotOptions)" - ResolvedAssemblies="@(_ResolvedUserAssemblies);@(_ShrunkFrameworkAssemblies)" + ResolvedAssemblies="@(_ResolvedAssemblies)" AotOutputDirectory="$(_AndroidAotBinDirectory)" IntermediateAssemblyDir="$(MonoAndroidIntermediateAssemblyDir)" LinkMode="$(AndroidLinkMode)" @@ -2742,7 +2717,7 @@ because xbuild doesn't support framework reference assemblies. Condition="'$(BundleAssemblies)' == 'True'" KeepTemp="$(AndroidMakeBundleKeepTemporaryFiles)" AndroidNdkDirectory="$(_AndroidNdkDirectory)" - Assemblies="@(_ResolvedUserAssemblies);@(_AndroidResolvedSatellitePaths);@(_ShrunkFrameworkAssemblies)" + Assemblies="@(_ResolvedAssemblies);@(_AndroidResolvedSatellitePaths)" IncludePath="$(MonoAndroidIncludeDirectory)" SupportedAbis="@(_BuildTargetAbis)" TempOutputPath="$(IntermediateOutputPath)" @@ -2760,7 +2735,7 @@ because xbuild doesn't support framework reference assemblies. BundleNativeLibraries="$(_BundleResultNativeLibraries)" EmbedAssemblies="$(EmbedAssembliesIntoApk)" ResolvedUserAssemblies="@(_ResolvedUserAssemblies);@(_AndroidResolvedSatellitePaths)" - ResolvedFrameworkAssemblies="@(_ShrunkFrameworkAssemblies)" + ResolvedFrameworkAssemblies="@(_ResolvedFrameworkAssemblies)" NativeLibraries="@(AndroidNativeLibrary)" ApplicationSharedLibraries="@(_ApplicationSharedLibrary)" AdditionalNativeLibraryReferences="@(_AdditionalNativeLibraryReferences)" @@ -2789,7 +2764,7 @@ because xbuild doesn't support framework reference assemblies. BundleNativeLibraries="$(_BundleResultNativeLibraries)" EmbedAssemblies="$(EmbedAssembliesIntoApk)" ResolvedUserAssemblies="@(_ResolvedUserAssemblies);@(_AndroidResolvedSatellitePaths)" - ResolvedFrameworkAssemblies="@(_ShrunkFrameworkAssemblies)" + ResolvedFrameworkAssemblies="@(_ResolvedFrameworkAssemblies)" NativeLibraries="@(AndroidNativeLibrary)" ApplicationSharedLibraries="@(_ApplicationSharedLibrary)" AdditionalNativeLibraryReferences="@(_AdditionalNativeLibraryReferences)"