Add escape hatch for not setting a default PublishRuntimeIdentifier value.#52566
Merged
baronfel merged 1 commit intodotnet:mainfrom Jan 21, 2026
Merged
Conversation
…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.
Member
Author
Member
Author
|
CC @vitek-karas, we need this for preview 1 |
Member
|
I think I'm also running into this problem at: |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets
Show resolved
Hide resolved
jonathanpeppers
approved these changes
Jan 20, 2026
Member
jonathanpeppers
left a comment
There was a problem hiding this comment.
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
baronfel
approved these changes
Jan 21, 2026
Member
baronfel
left a comment
There was a problem hiding this comment.
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?
rolfbjarne
added a commit
to dotnet/macios
that referenced
this pull request
Jan 27, 2026
rolfbjarne
added a commit
to dotnet/macios
that referenced
this pull request
Jan 27, 2026
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.
Member
|
/backport to release/10.0.2xx |
Contributor
|
Started backporting to |
rolfbjarne
added a commit
to dotnet/macios
that referenced
this pull request
Jan 27, 2026
rolfbjarne
added a commit
to dotnet/macios
that referenced
this pull request
Jan 27, 2026
…fier' values. (#24563) References: * https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2691518 * dotnet/sdk@3d6f592 * dotnet/sdk#52566 Backport of #24562.
jonathanpeppers
added a commit
to dotnet/android
that referenced
this pull request
Jan 27, 2026
…10730) Context: dotnet/sdk#52566 Newer .NET SDKs want this value to be set, to prevent a restore of your desktop OS's RID.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
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.