Skip to content

Remove NativeAOT runtime-pack override after dotnet/sdk#55750 ships #12362

Description

@jonathanpeppers

Android framework version

net11.0-android (Preview)

Affected platform version

.NET 11 SDK containing dotnet/sdk#55750

Description

Microsoft.Android.Sdk.NativeAOT.targets currently rewrites the .NET SDK's KnownRuntimePack metadata for Microsoft.NETCore.App NativeAOT packs. It pins LatestRuntimeFrameworkVersion and appends android-arm to RuntimePackRuntimeIdentifiers.

This was added as an Android-side workaround because the .NET SDK did not advertise android-arm for the NativeAOT runtime pack. dotnet/sdk#55750 adds that RID to the SDK's built-in KnownRuntimePack metadata.

Once dotnet/sdk#55750 is merged and available in the SDK used by this repository, remove the workaround from src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets:

<!-- Outer restores use RuntimeIdentifiers; RuntimeIdentifier is only set in per-RID inner builds. -->
<ItemGroup>
  <_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>

Context: #12356 (comment)

Steps to Reproduce

  1. Wait for Add android-arm to NativeAOT runtime pack RIDs sdk#55750 to merge and flow into the .NET SDK consumed by dotnet/android.
  2. Remove the Android-side KnownRuntimePack override above.
  3. Restore a NativeAOT Android project with RuntimeIdentifiers=android-arm.
  4. Verify project.assets.json selects Microsoft.NETCore.App.Runtime.NativeAOT.android-arm and does not fall back to Microsoft.NETCore.App.Runtime.NativeAOT.linux-bionic-arm.

Did you find any workaround?

Keep the existing Android-side override until the updated SDK is available.

Relevant log output

N/A

Activity

  1. added
    needs-triageIssues that need to be assigned.
    and removed
    needs-triageIssues that need to be assigned.
    on Aug 12, 2026
  2. added this to the .NET 11 milestone on Aug 12, 2026
  3. added
    Area: App+Library BuildIssues when building Library projects or Application projects.
    and removed
    needs-triageIssues that need to be assigned.
    on Aug 12, 2026
  4. james-allison commented on Aug 13, 2026

    @james-allison

    @jonathanpeppers I think there's an issue with this in Dotnet 11 - Preview 7. I've likely misunderstood something, but I had to change this property in Microsoft.Android.Sdk.BundledVersions.targets to avoid errors referencing what looks like it must be an internal build (11.0.0-preview.7.26378.119?).

     <MicrosoftNETCoreAppRefPackageVersion>11.0.0-preview.7.26381.103</MicrosoftNETCoreAppRefPackageVersion>
    

    I had been getting these errors:

    error NU1102: Unable to find package Microsoft.NETCore.App.Runtime.NativeAOT.android-arm64 with version (= 11.0.0-preview.7.26378.119)
    error NU1102:   - Found 21 version(s) in nuget.org [ Nearest version: 11.0.0-preview.7.26381.103 ]
    error NU1102:   - Found 0 version(s) in /usr/share/dotnet/library-packs
    error NU1102: Unable to find package runtime.linux-x64.Microsoft.DotNet.ILCompiler with version (= 11.0.0-preview.7.26378.119)
    error NU1102:   - Found 124 version(s) in nuget.org [ Nearest version: 11.0.0-preview.7.26381.103 ]
    error NU1102:   - Found 0 version(s) in /usr/share/dotnet/library-packs
    

    That got my NativeAOT Android build further - but I'm still hitting issues that look like its not finding the NDK correctly.

    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: Could not link native shared library: libXXXXXX.so
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007:
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: cannot open /crtbegin_so.o: No such file or directory
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: cannot open libc++_static.a: No such file or directory
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: cannot open libc++abi.a: No such file or directory
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: unable to find library -ldl
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: unable to find library -lz
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: unable to find library -llog
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: unable to find library -lm
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: unable to find library -lc
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: cannot open /libclang_rt.builtins-aarch64-android.a: No such file or directory
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: cannot open /libunwind.a: No such file or directory
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007: stderr | ld: error: cannot open /crtend_so.o: No such file or directory
    20:07:28     /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/37.0.0-preview.7.2131/targets/Microsoft.Android.Sdk.NativeAOT.targets(352,5): error XA3007:   
    
  5. akoeplinger commented on Aug 13, 2026

    @akoeplinger
    Member

    Yeah you'll need to change the property to get the correct version. The error about NDK is something else, I think you'll need to collect a binlog to see why the NDK isn't found.

    @jonathanpeppers I think this should also be using DotNetRuntimePacksVersion in

    <!-- NativeAOT Android runtime packs -->
    <PackageDownload Include="Microsoft.NETCore.App.Runtime.NativeAOT.android-arm" Version="[$(MicrosoftNETCoreAppRefPackageVersion)]" />
    <PackageDownload Include="Microsoft.NETCore.App.Runtime.NativeAOT.android-arm64" Version="[$(MicrosoftNETCoreAppRefPackageVersion)]" />
    <PackageDownload Include="Microsoft.NETCore.App.Runtime.NativeAOT.android-x64" Version="[$(MicrosoftNETCoreAppRefPackageVersion)]" />

    That said DotNetRuntimePacksVersion is already set to MicrosoftNETCoreAppRefPackageVersion but I'm not sure that's what you want since it'd mean you need to sync exactly to the version that is being released? or is that workloads.csproj just being used inside of the android repo for tests?

  6. jonathanpeppers commented on Aug 13, 2026

    @jonathanpeppers
    MemberAuthor

    Yeah you'll need to change the property to get the correct version. The error about NDK is something else, I think you'll need to collect a binlog to see why the NDK isn't found.

    @jonathanpeppers I think this should also be using DotNetRuntimePacksVersion in

    <!-- NativeAOT Android runtime packs -->
    <PackageDownload Include="Microsoft.NETCore.App.Runtime.NativeAOT.android-arm" Version="[$(MicrosoftNETCoreAppRefPackageVersion)]" />
    <PackageDownload Include="Microsoft.NETCore.App.Runtime.NativeAOT.android-arm64" Version="[$(MicrosoftNETCoreAppRefPackageVersion)]" />
    <PackageDownload Include="Microsoft.NETCore.App.Runtime.NativeAOT.android-x64" Version="[$(MicrosoftNETCoreAppRefPackageVersion)]" />

    That said DotNetRuntimePacksVersion is already set to MicrosoftNETCoreAppRefPackageVersion but I'm not sure that's what you want since it'd mean you need to sync exactly to the version that is being released? or is that workloads.csproj just being used inside of the android repo for tests?

    Our behavior also looked wrong here:

  7. filipnavara commented on Sep 10, 2026

    @filipnavara
    Member

    dotnet/sdk#55750 was merged. Yet .NET 11 RC 1 still shipped with workload packs that reference non-existing package versions and thus make NativeAOT publish unusable.

    Current workaround:

      <!-- Restore SDK-selected NativeAOT packs until dotnet/android#12362 is fixed.
           The RC 1 SDK already includes android-arm; the workload override pins an unpublished runtime version. -->
      <Target Name="RestoreSdkNativeAotRuntimePacks" BeforeTargets="ProcessFrameworkReferences"
              Condition="'$(PublishAot)' == 'true' and '@(_AndroidNetCoreAppNativeAotKnownRuntimePack)' != ''">
        <ItemGroup>
          <KnownRuntimePack Remove="@(KnownRuntimePack->WithMetadataValue('Identity', 'Microsoft.NETCore.App')->WithMetadataValue('RuntimePackLabels', 'NativeAOT'))" />
          <KnownRuntimePack Include="@(_AndroidNetCoreAppNativeAotKnownRuntimePack)" />
        </ItemGroup>
      </Target>
  8. jonathanpeppers commented on Sep 10, 2026

    @jonathanpeppers
    MemberAuthor

    I don't think we could fix this until RC 2 code flow came in. But I think we can fix now, I'm checking on it.

  9. added a commit that references this issue on Sep 11, 2026
    381b445
  10. locked and limited conversation to collaborators on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App+Library BuildIssues when building Library projects or Application projects.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions