Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

dotnet publish commandline with platform parameter value of "Any CPU" for a .NET Core Web API Application

Ask Question

We developed an a .NET Core Web API application using the following technologies:

-NET Core (3.1)

-Visual Studio 2019

Unfortunately, we have to deploy said application to the following environment:

-32-bit Environment

-Windows Server 2008 R2 Enterprise (Service Pack 1)

-IIS Version 7.5

-8 GB RAM

( Also, it needs to be an In-Process because we Only want the .NET Core Web API Application to be within IIS Server )*

On my Development Computer that uses Visual Studio 2019, I installed Net Core 3.1 x86 sdk version ( i.e., the .NET Core 32-Bit version )

Prior to Visual Studio 2019's Build, we have to specify Platform target: "Any CPU" because if we specified "x86" then when we deploy to our IIS Server x86 platform, it throws a weird 500 level error when we run the .NET Core Web API in IIS.

We are trying to use dotnet commandline to publish the .NET Core Web API application.

D:\AppCodeArena\BlahBlahProject>dotnet publish -c Release /p:Platform:"Any CPU" /p:EnvironmentName=UAT BlahBlahProject.csproj --output D:\IISDeployment\Uploader.BlahBlahProject

Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core

MSBUILD : error MSB1006: Property is not valid. Switch: Platform:Any

Unfortunately, it states above that

/p:Platform:"Any CPU"

is invalid? Could someone please post the correct dotnet publish... command that will allow use to specify "Any CPU" for the platform?

if there is anyway to use MSBuild commandline instead of "dotnet publish" commandline then could someone please post how to do so?

Thanks, however, could you please correct your posted command? It is Incorrect tob have the arguments '..../p:EnvironmentName=Myproject.csproj....' since project file name is Not the same as the Environment Name. crazyTech Jun 4, 2020 at 13:16 @crazyTech My bad. I just update the command-line. Could you fix it by using my updated command line? Jokies Ding Jun 4, 2020 at 17:34

Build parameters are passed to msbuild via the dotnet command using the following syntax:

/p:Platform="Any CPU"

Notice the = rather than the : you use in your command.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.