From e3791f12005bf628ea2f893794df98fdb9ef8022 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Sat, 27 Jun 2026 22:41:33 +0200 Subject: [PATCH 1/2] [TrimmableTypeMap] Fix DesignTimeBuildSignAndroidPackage on NativeAOT The NativeAOT trimmable typemap is consumed only in the inner per-RID ILC build (via _AddTrimmableTypeMapAssembliesToIlc -> _ReadGeneratedTrimmableTypeMapAssemblies), which cannot generate it: _GenerateTrimmableTypeMap is gated to the outer build (_OuterIntermediateOutputPath == ''). Its only trigger is AfterTargets="CoreCompile", which does not fire when compilation is up-to-date - e.g. the IDE's separate "Compile" then "SignAndroidPackage" invocations (BuildingInsideVisualStudio=true). The outer build therefore never generated obj/.../typemap/typemap-assemblies.txt and the inner build failed with "Trimmable typemap assembly list ... was not found". Force _GenerateTrimmableTypeMap to run in the outer build before _ResolveAssemblies spawns the inner per-RID build. _ResolveAssemblies runs after compilation (it consumes @(IntermediateAssembly)), so the generator still observes the compiled app assembly. Mirrors the CoreCLR _AddTrimmableTypeMapToLinker target, which forces generation before the (outer) ILLink. Verified locally: DesignTimeBuildSignAndroidPackage(NativeAOT) now passes (was failing); DesignTimeBuildSignAndroidPackage(CoreCLR) continues to pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...oid.Sdk.TypeMap.Trimmable.NativeAOT.targets | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.NativeAOT.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.NativeAOT.targets index 6ef82b37f11..e5c15a68853 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.NativeAOT.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.NativeAOT.targets @@ -41,6 +41,24 @@ + + + From e68ee2c1c74c6a25189b1001a02cb822baaa4e09 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Sun, 28 Jun 2026 16:56:33 +0200 Subject: [PATCH 2/2] Address review: gate on _OuterIntermediateOutputPath, not RuntimeIdentifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "outer build" is the build that is not an inner per-RID build, which is determined by '$(_OuterIntermediateOutputPath)' == '' — the same discriminator _GenerateTrimmableTypeMap itself uses. The previous 'RuntimeIdentifier == '' condition missed the single-RID outer build (e.g. -p:RuntimeIdentifier=android-arm64), where RuntimeIdentifier is non-empty but the build is still the outer one, leaving the typemap ungenerated and reproducing the same failure this change fixes. The inner build receives _OuterIntermediateOutputPath via _ResolveAssemblies AdditionalProperties, so the target is still correctly skipped there. Verified locally: DesignTimeBuildSignAndroidPackage(NativeAOT) and (CoreCLR) both pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...ndroid.Sdk.TypeMap.Trimmable.NativeAOT.targets | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.NativeAOT.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.NativeAOT.targets index e5c15a68853..fb655661a24 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.NativeAOT.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.NativeAOT.targets @@ -42,9 +42,10 @@