使用 VS2010 的 msbuild 构建时,我可以从命令行设置平台工具集吗?

当我从命令行使用 msbuild 构建 VS2010 时,我可以在不编辑 vcxproj 文件的情况下从命令行将平台工具集更改为 v90(即 Visual Studio 2008 工具链)吗?

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

推荐答案

是的,您可以在不更改 vcxproj 文件的情况下设置 PlatformToolset.

Yes you can set PlatformToolset without change the vcxproj file.

如果您打开一个 vcxproj 文件,您会看到有一个 PlatformToolset 属性.对于visual studio 2012,它是v110;对于VS2010,是v100;VS2008 为 v90.

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.

您可以使用 /p:PlatformToolset=v110/v100/v90 覆盖此属性以更改工具链.

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

注意:有时,msbuild 失败并返回错误 Unsupported platformtoolset value,这主要是因为您没有指定 VisualStudioVersion.

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

相关文章