Skip to content

Conversation

@rolfbjarne
Copy link
Member

@rolfbjarne rolfbjarne commented Jan 20, 2026

This adds an escape hatch (setting 'UseDefaultPublishRuntimeIdentifier=false') when trying to set a default PublishRuntimeIdentifier value.

This is necessary when publishing with RuntimeIdentifiers (plural), but without a RuntimeIdentifier, which is valid when building universal apps for macOS and Mac Catalyst (the netX-macos and netX-maccatalyst target frameworks).

When building such an app, the project file will set RuntimeIdentifiers (plural):

<TargetFramework>net11.0-macos</TargetFramework>
<RuntimeIdentifiers>osx-x64;osx-arm</RuntimeIdentifiers>

and then during build/publish, the macOS SDK will run two inner builds, with RuntimeIdentifiers unset, and RuntimeIdentifier set to each of the rids (and at the end merge the result into a single app).

The problem is that the outer build, where RuntimeIdentifiers is set, but RuntimeIdentifier isn't, PublishRuntimeIdentifier will now get a default value (after PR #51765), and that will set RuntimeIdentifier, which will confuse our outer build.

Also note that we can't set PublishRuntimeIdentifier to the desired runtime identifiers (plural), because PublishRuntimeIdentifier is only valid for a single runtime identifier.

…alue.

This adds an escape hatch (setting 'UseDefaultPublishRuntimeIdentifier=false') when trying to set a default PublishRuntimeIdentifier value.

This is necessary when publishing with RuntimeIdentifiers (plural), but without a RuntimeIdentifier, which is valid when building universal apps for macOS and Mac Catalyst (the netX-macos and netX-maccatalyst target frameworks).

When building such an app, the project file will set RuntimeIdentifiers (plural):

    <TargetFramework>net11.0-macos</TargetFramework>
    <RuntimeIdentifiers>osx-x64;osx-arm</RuntimeIdentifiers>

and then during build/publish, the macOS SDK will run two inner builds, with RuntimeIdentifiers unset, and RuntimeIdentifier set to each of the rids (and at the end merge the result into a single app).

The problem is that the outer build, where RuntimeIdentifiers is set, but RuntimeIdentifier isn't, PublishRuntimeIdentifier will now get a default value (after PR dotnet#51765), and that will set RuntimeIdentifier, which will confuse our outer build.

Also note that we can't set PublishRuntimeIdentifier to the desired runtime identifiers (plural), because PublishRuntimeIdentifier is only valid for a single runtime identifier.
Copilot AI review requested due to automatic review settings January 20, 2026 10:04
@rolfbjarne
Copy link
Member Author

CC @baronfel (since this regressed in #51765).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@rolfbjarne
Copy link
Member Author

CC @vitek-karas, we need this for preview 1

@vitek-karas vitek-karas added this to the 11.0.1xx milestone Jan 20, 2026
@vitek-karas vitek-karas requested a review from baronfel January 20, 2026 15:20
@jonathanpeppers
Copy link
Member

I think I'm also running into this problem at:

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

So, prior to this change (on Windows):

> dotnet new android
> dotnet build -c Release -p:PublishAot=true -bl
Restore complete (8.8s)
    info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  hellonativeaot net11.0-android win-x64 failed with 1 error(s) and 1 warning(s) (0.2s)
    D:\src\xamarin-android\bin\Debug\lib\packs\Microsoft.Android.Sdk.Windows\36.1.99\targets\Microsoft.Android.Sdk.Tooling.targets(61,5): error XA0035: Unable to determine the Android ABI from the value 'win-x64'. Edit the project file in a text editor and set the 'RuntimeIdentifiers' MSBuild property to contain only valid identifiers for the Android platform.

Build failed with 1 error(s) and 1 warning(s) in 9.3s

Then afterward:

> dotnet build -c Release -p:PublishAot=true -bl -p:UseDefaultPublishRuntimeIdentifier=false
Restore complete (0.7s)
...
Build succeeded with 3 warning(s) in 25.4s

Copy link
Member

@baronfel baronfel left a comment

Choose a reason for hiding this comment

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

Nice scoping to limit the blast radius 👍

I know this is needed for blocking - can you do a follow-up to find a place to add a test to pin the expected behavior?

@baronfel baronfel merged commit 6e4836d into dotnet:main Jan 21, 2026
33 checks passed
jonathanpeppers added a commit to dotnet/android that referenced this pull request Jan 27, 2026
Context: dotnet/sdk#52566

Newer .NET SDKs want this value to be set, to prevent a restore of your desktop OS's RID.
@marcpopMSFT
Copy link
Member

/backport to release/10.0.2xx

@github-actions
Copy link
Contributor

Started backporting to release/10.0.2xx (link to workflow run)

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.

5 participants