Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'))" />
<KnownRuntimePack Remove="@(_AndroidNetCoreAppNativeAotKnownRuntimePack)" />
<KnownRuntimePack Include="@(_AndroidNetCoreAppNativeAotKnownRuntimePack)">
<LatestRuntimeFrameworkVersion>$(MicrosoftNETCoreAppRefPackageVersion)</LatestRuntimeFrameworkVersion>
<RuntimePackRuntimeIdentifiers>%(RuntimePackRuntimeIdentifiers);android-arm</RuntimePackRuntimeIdentifiers>
</KnownRuntimePack>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Text.RegularExpressions;

using NUnit.Framework;
using Xamarin.Android.Tasks;
Expand Down Expand Up @@ -42,6 +43,38 @@ 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."
);

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]
public void BuildNativeAot_WithoutNdk ()
{
Expand Down
Loading