Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I set the platform toolset from the command line when building with VS2010's msbuild?

When I'm building a VS2010 with msbuild from the command line, can I change the platform toolset to v90 (i.e. Visual Studio 2008 toolchain) from the command line, without editing the vcxproj file?

I'm using the following command line in my build script currently:

mysystemf("msbuild %s.vcxproj /t:rebuild /p:configuration=release,platform=%s", prjname, platform);
like image 485
sashoalm Avatar asked Jul 18 '12 15:07

sashoalm


People also ask

How do I run MSBuild from command prompt?

To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.

How do I change the platform toolset in Visual Studio?

To change the platform toolsetIn the properties page, select Platform Toolset and then select the toolset you want from the drop-down list. For example, if you've installed the Visual Studio 2010 toolset, select Visual Studio 2010 (v100) to use it for your project. Choose the OK button to save your changes.

What is MSBuild command?

By invoking msbuild.exe on your project or solution file, you can orchestrate and build products in environments where Visual Studio isn't installed. Visual Studio uses MSBuild to load and build managed projects.


2 Answers

Yes you can set PlatformToolset without change the vcxproj file.

If you open a vcxproj file, you'll see that there is a PlatformToolset property. For visual studio 2012, it is v110; For VS2010, it is v100; For VS2008, it is v90.

You could overwrite this property with /p:PlatformToolset=v110/v100/v90 to change the toolchain.

Note: Sometimes, msbuild failed with error Unsupported platformtoolset value, it is mostly because you have not specify the VisualStudioVersion.

like image 86
Jichao Avatar answered Sep 22 '22 14:09

Jichao


I found the answer in MSDN:

To rebuild your project with the Visual C++ 9.0 toolset, type either of the following commands:

msbuild myproject.vcxproj /p:PlatformToolset=v90 /t:rebuild

like image 29
sashoalm Avatar answered Sep 21 '22 14:09

sashoalm