Skip to content

[NativeAOT] Use SDK-selected runtime pack version - #12489

Open
simonrozsival with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-nativeaot-publish-error
Open

[NativeAOT] Use SDK-selected runtime pack version#12489
simonrozsival with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-nativeaot-publish-error

Conversation

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

NativeAOT publish could pair the SDK-selected ILCompiler with an Android workload-pinned runtime pack. The resulting incompatible System.Private.CoreLib lacked AsyncHelpers.RestoreInlinedFrameContexts.

  • Runtime-pack resolution

    • Remove the Android LatestRuntimeFrameworkVersion override.
    • Preserve the android-arm RID extension.
    • Let the SDK select coherent ILCompiler and NativeAOT runtime-pack versions.
  • Regression coverage

    • Verify NativeAOT restore ignores the workload runtime version property and uses the SDK-owned version.

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix NativeAOT publish failure related to missing RestoreInlinedFrameContexts [NativeAOT] Use SDK-selected runtime pack version Aug 24, 2026
Copilot AI requested a review from simonrozsival August 24, 2026 10:17
@simonrozsival
simonrozsival marked this pull request as ready for review August 25, 2026 13:04
Copilot AI lite review requested due to automatic review settings August 25, 2026 13:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses NativeAOT publish failures caused by mixing an SDK-selected ILCompiler with an Android workload–pinned NativeAOT runtime pack by removing the Android-side runtime-pack version override so the .NET SDK selects a coherent set of versions. It also adds regression coverage intended to ensure restore is not influenced by the workload-pinned MicrosoftNETCoreAppRefPackageVersion value.

Changes:

  • Remove the LatestRuntimeFrameworkVersion override from the NativeAOT KnownRuntimePack entry so runtime-pack versions are SDK-selected.
  • Preserve the android-arm RID extension for NativeAOT runtime pack restore.
  • Add a new test intended to validate restore behavior with an invalid MicrosoftNETCoreAppRefPackageVersion.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets Stops overriding NativeAOT runtime-pack version so SDK can select coherent ILCompiler/runtime-pack versions; keeps android-arm RID extension.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs Adds a regression test for NativeAOT restore version selection behavior.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +53 to +60
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."
);
}
@simonrozsival

Copy link
Copy Markdown
Member

@copilot address the code review and improve the test or add more tests

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address the code review and improve the test or add more tests

Updated RestoreNativeAot_UsesSdkRuntimePackVersion to parse project.assets.json and assert that the resolved NativeAOT runtime pack's version is not 0.0.0, which actually proves the invalid MicrosoftNETCoreAppRefPackageVersion is ignored for runtime-pack version selection (previously it only checked that Restore succeeded).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NativeAOT publish fails when AsyncHelpers.RestoreInlinedFrameContexts is missing

3 participants