From f401019e8670db3159f59d176bacafaa1492ae3e Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 20 Feb 2025 16:27:21 -0600 Subject: [PATCH 1/2] [nativeaot] default to `$(PublishAotUsingRuntimePack)=true` Context: https://github.com/xamarin/xamarin-macios/blob/d4baff4c6847a413e6a9c60089edfff50611ea9b/dotnet/targets/Xamarin.Shared.Sdk.props#L192 `$(PublishAotUsingRuntimePack)` needs to be `true` for any NativeAOT scenario on mobile. This setting is more useful for desktop platforms, as you aren't cross-compiling anything. Desktop builds can potentially use the packs from the .NET SDK as the host and target match. xamarin/xamarin-macios also defaults `$(PublishAotUsingRuntimePack)=true` when `$(PublishAot)=true`, so we should be safe to follow suit. --- samples/NativeAOT/NativeAOT.csproj | 3 +-- .../targets/Microsoft.Android.Sdk.DefaultProperties.targets | 1 + .../Tests/Xamarin.Android.Build.Tests/BuildTest2.cs | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/samples/NativeAOT/NativeAOT.csproj b/samples/NativeAOT/NativeAOT.csproj index 18922a65b67..8643c56ef1b 100644 --- a/samples/NativeAOT/NativeAOT.csproj +++ b/samples/NativeAOT/NativeAOT.csproj @@ -11,9 +11,8 @@ apk android-arm64 - + true - true diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets index 65df9f5096a..f40d1958c45 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets @@ -29,6 +29,7 @@ <_AndroidRuntime Condition=" '$(PublishAot)' == 'true' and '$(UseMonoRuntime)' != 'true' ">NativeAOT <_AndroidRuntime Condition=" '$(PublishAot)' != 'true' and '$(UseMonoRuntime)' != 'true' ">CoreCLR <_AndroidRuntime Condition=" '$(_AndroidRuntime)' == '' ">MonoVM + true <_IsPublishing Condition=" '$(_IsPublishing)' == '' and '$(_AndroidRuntime)' == 'NativeAOT' ">true diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs index c82fc7fbd2c..e687e1e605d 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs @@ -133,7 +133,6 @@ public void NativeAOT () } }; proj.SetProperty ("PublishAot", "true"); - proj.SetProperty ("PublishAotUsingRuntimePack", "true"); proj.SetProperty ("AndroidNdkDirectory", AndroidNdkPath); proj.SetProperty ("_ExtraTrimmerArgs", "--verbose"); From a4e593b0b52df2cc6a68162cbd7945fb4f3b7e96 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 20 Feb 2025 21:25:27 -0600 Subject: [PATCH 2/2] Fix typo in PublishAotUsingRuntimePack property --- .../targets/Microsoft.Android.Sdk.DefaultProperties.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets index f40d1958c45..de279984448 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets @@ -29,7 +29,7 @@ <_AndroidRuntime Condition=" '$(PublishAot)' == 'true' and '$(UseMonoRuntime)' != 'true' ">NativeAOT <_AndroidRuntime Condition=" '$(PublishAot)' != 'true' and '$(UseMonoRuntime)' != 'true' ">CoreCLR <_AndroidRuntime Condition=" '$(_AndroidRuntime)' == '' ">MonoVM - true + true <_IsPublishing Condition=" '$(_IsPublishing)' == '' and '$(_AndroidRuntime)' == 'NativeAOT' ">true