RuntimeIdentifiers doesn't set PlatformTarget
See original GitHub issueFrom @davidmatson on March 21, 2017 2:47
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net452</TargetFramework>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<AssemblyName>Testx64</AssemblyName>
</PropertyGroup>
</Project>
Expected: 64-bit assembly
Actual: AnyCPU assembly
Current workaround is to add:
<PlatformTarget>x64</PlatformTarget>
Copied from original issue: dotnet/roslyn-project-system#1804
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Relationship between PlatformTarget and ...
NET 5.0 class libraries that runs on Windows for 64bit, you have to specify both TFM and RuntimeIdentifier (usually called RID). Therefore we ......
Read more >The RuntimeIdentifier platform 'win10-x64' and ...
When I run the MAUI UWP application I am getting below error "The RuntimeIdentifier platform 'win10-x64' and the PlatformTarget 'x86' must ...
Read more >Build in Visual Studio runs fine, msbuild fails
Setting the runtime identifier in the .cproj file of the to all .netstandard projects lets the build pass, but that cannot be the...
Read more >Platform vs. PlatformTarget In Any .NET Build - doughnuts.dev
PlatformTarget appears to be set here (if not already set) based off of the RuntimeIdentifier. And to confirm that this all happens before...
Read more >.NET RuntimeIdentifier vs RuntimeIdentifiers - David Gardiner
A Runtime Identifier (RID) is used to identify target platforms where a .NET Core application runs. They come into play when packages ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It already does set $(PlatformTarget) for you to x64 in this case if you haven’t set it yourself.
Similarly, if you build on Windows and set $(PlatformTarget), it will pick the win7-x64 $(RuntimeIdentifier) for you. When we pick for you, we do not add path segments. This is safe because the build invocation with something unset is different from when it’s set and the goal is different build gestures that change these parameters go to different directories.
There’s a good subset of common cases where you can stick to either the traditional Platform/PlatformTarget or RuntimeIdentifier/RuntimeIdentifiers, but not mix them, and you won’t get any project file content or path duplication.
The variables that can never mismatch are $(PlatformTarget) (used to stamp exe) and $(RuntimeIdentifier) (used to resolve native nuget assets). With that said, we do not issue a warning or error in this case today.
$(Platform) is a little different. It is just an extra dimension to the configuration. It does not necessarily affect other things. By default Platform=x64 implies PlatformTarget=x64, but you can change in fact change them independently. It is not uncommon to just use empty default $(Platform)=AnyCPU but still emit platform-specific binaries. It has also always been possible (for classic csproj too) to have Platform=x86 (set by configuration manager), but PlatformTarget=x64 (set by build property page).
It’s not that easy. We certainly can’t remove an explicit RuntimeIdentifier=win7-x64 because there can be a separate build invocation with win10-x64 and that needs to go to a distinct directory. Removing the x64 part is more promising as it’s the only part that is actually redundant, but it would make it overly complicated to predict the output path of any given project and build invocation. Platform being much like Configuration (as explained above) means that it is part of the output path in the same way (with the long-standing convention that AnyCPU gets an empty segment). While bizarre, it is possible to have conditions based on $(Platform) such that $(Platform)=x64/$(PlatformTarget)=x64 builds something different than $(Platform)=AnyCPU, $(PlatformTarget)=x64.
In the fully general case, this can get very complex.
I see two follow-ups here:
I think this is by design. I believe the plural
RuntimeIdentifiers
property only affects what runtime-specific packages NuGet restores (allowing you to do a rid-specific publish for example later). If you want to build for x64, then I think you would set the singularRuntimeIdentifier
property instead.@nguerrera or @eerhardt may be able to provide more insight.