-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add escape hatch for not setting a default PublishRuntimeIdentifier value. #52566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add escape hatch for not setting a default PublishRuntimeIdentifier value. #52566
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.
There was a problem hiding this 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.
|
CC @vitek-karas, we need this for preview 1 |
|
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
left a comment
There was a problem hiding this 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
baronfel
left a comment
There was a problem hiding this 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?
Context: dotnet/sdk#52566 Newer .NET SDKs want this value to be set, to prevent a restore of your desktop OS's RID.
|
/backport to release/10.0.2xx |
|
Started backporting to |
…fier' values. (#24563) References: * https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2691518 * dotnet/sdk@3d6f592 * dotnet/sdk#52566 Backport of #24562.
…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 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.