developer82
developer82

Reputation: 13713

MSBuild ignores the desired configuration

I'm trying to build a Visual Studio 2019 solution from command line (though a PowerShell script), I need to have 2 builds - one for 64-bit and one for 32-bit though the script.

From Configuration Manager I have added x86 and x64 platforms to the Platform: enter image description here

And in the project properties I have set up the Platform target accordingly: enter image description here

I'm using the following command lines to build with MSBuild:

& $msbuildPath ../MyApp.Desktop.sln -t:Rebuild -p:Configuration=Release /p:Platform=x86
& $msbuildPath ../MyApp.Desktop.sln -t:Rebuild -p:Configuration=Release /p:Platform=x64

But it seems to ignore the /p:Platform because it does not matter if I state x86 or x64 it always builds the "Active" platform set in Configuration Manager. But, if I put in platform an invalid value (for instance x123) the build would fail because that does not exist.

How can I make MSBuild actually build with the stated /p:Platform?

Upvotes: 0

Views: 1075

Answers (1)

Mr Qian
Mr Qian

Reputation: 23780

If you build your sln file, you should change the solution platform rather than the project platform.

Please try the following steps:

1) first, delete every project platform and do a clean for your project.And only retain the platform Any CPU.

enter image description here

2) add the new x64 and x86 platform for the solution platform

enter image description here

3) close VS Instance, delete the bin and obj folder of every project

then run your powershell with /p:Platform=x64 or x86. And it works well in my side. And it can return x86 or x64 output files without any problems.

enter image description here

Upvotes: 1

Related Questions