From 9229469436f4f64d1a416a31f4cffd52c3140e46 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Mon, 24 Aug 2026 09:45:12 +0000
Subject: [PATCH 1/3] Initial plan
From b04b9cfc5b6480850ee9dafa77d22485a259a227 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Mon, 24 Aug 2026 10:15:51 +0000
Subject: [PATCH 2/3] Fix NativeAOT runtime pack version selection
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
---
.../Microsoft.Android.Sdk.NativeAOT.targets | 1 -
.../NativeAotBuildTests.cs | 17 +++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
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 9ec28273a23..12d881cc44a 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
@@ -40,7 +40,6 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
<_AndroidNetCoreAppNativeAotKnownRuntimePack Include="@(KnownRuntimePack->WithMetadataValue('Identity', 'Microsoft.NETCore.App')->WithMetadataValue('RuntimePackLabels', 'NativeAOT'))" />
- $(MicrosoftNETCoreAppRefPackageVersion)
%(RuntimePackRuntimeIdentifiers);android-arm
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs
index 9f1cfab9198..8bbf82a478f 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs
@@ -42,6 +42,23 @@ public void RestoreNativeAot_AndroidArmRuntimePack ()
);
}
+ [Test]
+ public void RestoreNativeAot_UsesSdkRuntimePackVersion ()
+ {
+ var proj = new XamarinAndroidApplicationProject {
+ IsRelease = true,
+ };
+ proj.SetRuntime (AndroidRuntime.NativeAOT);
+
+ using var builder = CreateApkBuilder ();
+ Assert.IsTrue (
+ builder.RunTarget (proj, "Restore", parameters: [
+ "MicrosoftNETCoreAppRefPackageVersion=0.0.0",
+ ]),
+ "Restore should use the .NET SDK's NativeAOT runtime pack version."
+ );
+ }
+
[Test]
public void BuildNativeAot_WithoutNdk ()
{
From f2583967c092d2c834b40296fcdef09dd306d842 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 25 Aug 2026 13:45:47 +0000
Subject: [PATCH 3/3] Strengthen NativeAOT restore regression test assertions
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
---
.../NativeAotBuildTests.cs | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs
index 8bbf82a478f..37e7dd72c8e 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs
@@ -1,4 +1,5 @@
using System.IO;
+using System.Text.RegularExpressions;
using NUnit.Framework;
using Xamarin.Android.Tasks;
@@ -57,6 +58,21 @@ public void RestoreNativeAot_UsesSdkRuntimePackVersion ()
]),
"Restore should use the .NET SDK's NativeAOT runtime pack version."
);
+
+ var intermediate = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath);
+ var assets = File.ReadAllText (Path.Combine (intermediate, "..", "project.assets.json"));
+
+ // Library entries in project.assets.json are keyed as "PackageId/Version".
+ var runtimePackMatch = Regex.Match (assets, "\"Microsoft\\.NETCore\\.App\\.Runtime\\.NativeAOT\\.[a-z0-9.-]+/([^\"]+)\"");
+ Assert.IsTrue (
+ runtimePackMatch.Success,
+ "Restore should select a NativeAOT runtime pack."
+ );
+ Assert.AreNotEqual (
+ "0.0.0",
+ runtimePackMatch.Groups [1].Value,
+ "Restore should ignore the invalid MicrosoftNETCoreAppRefPackageVersion and use the SDK-selected NativeAOT runtime pack version."
+ );
}
[Test]