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

二次信任 提交于 2019-12-18 03:37:12

问题


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);

回答1:


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.




回答2:


The PlatformToolset is configured as part of a PropertyGroup for the configuration.

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
  <ConfigurationType>Application</ConfigurationType>
  <UseDebugLibraries>true</UseDebugLibraries>
  <CharacterSet>Unicode</CharacterSet>
  <PlatformToolset>v90</PlatformToolset>
</PropertyGroup>

If you want to change toolsets from the command line, you should add a configuration for each toolset (easily done using the IDE) and then call that configuration for the build.

msbuild %s.vcxproj /t:rebuild /p:configuration=VC90Release,platform=%s




回答3:


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




回答4:


From here http://msdn.microsoft.com/en-us/library/bb397428

It says that adding /ToolsVersion:3.5 will build it as if it were a VS 2008 project



来源:https://stackoverflow.com/questions/11544563/can-i-set-the-platform-toolset-from-the-command-line-when-building-with-vs2010s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!