-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the bug
RuntimeIdentifier
in project file is ignored when building/publishing using dotnet build --self-contained
or dotnet publish --self-contained
. The runtime identifier of the SDK is always used.
To Reproduce
- Create a new app
- Update the .csproj to specify a
RuntimeIdentifier
that is not the same as the SDK you are using. For example, when using a Windows x64 SDK, specify:
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
- Build or publish as self-contained:
dotnet build --self-contained
dotnet publish --self-contained
Expected: The application is built/published using the RID specified in the project - win-x86
.
Actual: The application is built/published using the RID of the SDK - win-x64
- not the one explicitly set in the project.
Further technical details
For the repro steps above, MSBuild ends up invoked with:
-property:RuntimeIdentifier=win-x64 -property:_CommandLineDefinedRuntimeIdentifier=true
The SDK is explicitly adding the RuntimeIdentifier
property on the command line if self-contained is specified on the command line, but the runtime identifier is not. As a result, the SDK's RID is used, overriding any settings in the project.
sdk/src/Cli/dotnet/CommonOptions.cs
Lines 260 to 264 in a2c34bb
if (!UserSpecifiedRidOption(parseResult) && isSelfContained) | |
{ | |
var ridProperties = RuntimeArgFunc(GetCurrentRuntimeId()); | |
selfContainedProperties = selfContainedProperties.Concat(ridProperties); | |
} |
Environment info:
.NET SDK (reflecting any global.json):
Version: 7.0.100-preview.3.22179.4
Commit: c48f2c30ee
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win10-x64
This is a regression from 6.0.
We hit this trying to update the runtime repo to a newer SDK: dotnet/runtime#67771