From 1aef5e7da6c0e7d9d06317a4ff9ef1cd35fbc345 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Wed, 13 May 2026 17:13:37 -0700 Subject: [PATCH 1/4] [NativeAOT] Make workload linker the default for NativeAOT builds Change _AndroidUseWorkloadNativeLinker default from false to true so NativeAOT builds use the workload-provided linker and sysroot by default, removing the NDK requirement. Update SetRuntime(NativeAOT) to set _SkipNdkResolution=true so all existing NativeAOT tests exercise the NDK-free workload linker path. Update NativeAotBuildTests with three tests covering the full matrix: - BuildNativeAot_WithoutNdk: workload linker (default), no NDK -> succeeds - BuildNativeAot_WithNdkLinker: opt-out to NDK linker, with NDK -> succeeds - BuildNativeAot_WithoutNdk_WorkloadLinkerDisabled_Fails: opt-out, no NDK -> fails Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Assisted-by: Claude:claude-opus-4.6-1m --- .../Microsoft.Android.Sdk.NativeAOT.targets | 2 +- .../NativeAotBuildTests.cs | 35 ++++++++++++++----- .../Utilities/ProjectExtensions.cs | 1 + 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets index 53f327d7e73..6ad1523d89d 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets @@ -299,7 +299,7 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android. Outputs="$(NativeOutputPath)$(NativeBinaryPrefix)$(TargetName).so"> <_AndroidNativeAotSharedLibrary>$(NativeOutputPath)$(NativeBinaryPrefix)$(TargetName).so - <_AndroidUseWorkloadNativeLinker Condition=" '$(_AndroidUseWorkloadNativeLinker)' == '' ">false + <_AndroidUseWorkloadNativeLinker Condition=" '$(_AndroidUseWorkloadNativeLinker)' == '' ">true <_AndroidRuntimePackRuntime>NativeAOT + <_AndroidUseWorkloadNativeLinker Condition=" '$(_AndroidUseWorkloadNativeLinker)' == '' ">true <_AndroidJcwCodegenTarget Condition=" '$(_AndroidJcwCodegenTarget)' == '' ">JavaInterop1 <_AndroidTypeMapImplementation Condition=" '$(_AndroidTypeMapImplementation)' == '' ">managed @@ -299,7 +300,6 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android. Outputs="$(NativeOutputPath)$(NativeBinaryPrefix)$(TargetName).so"> <_AndroidNativeAotSharedLibrary>$(NativeOutputPath)$(NativeBinaryPrefix)$(TargetName).so - <_AndroidUseWorkloadNativeLinker Condition=" '$(_AndroidUseWorkloadNativeLinker)' == '' ">true