sdk: Dotnet build and publish don't have parameters for platform
Steps to reproduce
Have a csproj file with conditional configs as such:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
Expected behavior
There’s a configuration parameter (dotnet build -c Debug) (dotnet publish -c Debug) that fills in $(Configuration) so I expect there to be a parameter to fill in $(Platform)
Actual behavior
There is no parameter and specific configuration details don’t get applied because Platform does not get set to x64
Current Work-around
Explicitly setting the Platform EV for the current command prompt using
SET Platform=x64
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 9
- Comments: 20 (8 by maintainers)
You can pass it using
dotnet build /p:Platform=x64Shouldn’t that be added to the documentation then?
What worked for me was
/p:Platform=and not/p:Platform:That’s works for me https://github.com/dotnet/sdk/issues/9966#issuecomment-443468788
But why it’s not documented until now !!
In .NET 6, you can use the
-a|--archargument to specify the architecture of your build/publish/etc. See detailed documentation here. This doesn’t handle the general case where users might want anAnyCPUvalue for thePlatformMSBuild property, however.Valid question.
EDIT: it is documented, but not in an optimal way. I think the
-pargument should be a part of the synopsis and also be added to the Arguments section.I’ve spent at least an hour on this issue, tracking it down to something not obvious from the beginning:
dotnet buildrequires a minus-for-cand a slash/for/p. Many command line parses allow-and/to be used interchangeably.dotnet build -c:"Debug" /p:Platform:"Any CPU"Note for scripting: the Configuration and Platform names should be in quotes, as these are arbitrary names that can contain spaces. The defaults are “Debug”/“Release” and “Any CPU”, but you could rename them to “Custom Configuration Name” and “Custom Platform Name”.
Note: The “Any CPU” Platform by default produces AnyCPU (no space) output, but that can changed per project. The “Any CPU” Platform may produce one project as AnyCPU, one as x86 and another as x64. For more information, study the “Configuration Manager” in Visual Studio.