Msbuild 未对 Visual C++ 项目使用指定的工具集
Msbuild not using specified toolset for Visual C++ project
我有一台安装了并行 VS2015 和 VS2013 的机器,我正在尝试使用 VS2013 工具集 (v120) 构建一些东西。然而,尽管项目文件中有显式覆盖,它仍在尝试使用 v140。
C:\transfer\MathLib\testSse>msbuild Sse.vcxproj
Microsoft (R) Build Engine version 12.0.40629.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 23-Mar-17 12:35:07.
Project "C:\transfer\MathLib\testSse\Sse.vcxproj" on node 1 (default targets).
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build t
ools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 bui
ld tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-cli
ck the solution, and then selecting "Upgrade Solution...". [C:\transfer\MathLib\testSse\Sse.vcxproj]
Done Building Project "C:\transfer\MathLib\testSse\Sse.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\transfer\MathLib\testSse\Sse.vcxproj" (default target) (1) ->
(PlatformPrepareForBuild target) ->
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build
tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 b
uild tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-c
lick the solution, and then selecting "Upgrade Solution...". [C:\transfer\MathLib\testSse\Sse.vcxpro
j]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.16
C:\transfer\MathLib\testSse>notepad Sse.vcxproj
以下是项目文件的相关摘录:
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
我可以用这个命令覆盖它:
msbuild Sse.vcxproj /p:PlatformTooset=v120
然后编译,但这并没有真正解决问题,因为我在一个大型 Visual Studio 解决方案中有很多这样的东西,我需要它们都使用那个参数。除非我能以某种方式将 msbuild 覆盖参数放入解决方案中。
但是,是什么导致 msbuild
使用我未在任何地方提及的另一个工具集?
一种可能是我在 VS2015
之后安装了 VS2013
- 我想这有点不寻常。这可能是问题所在吗?
并且如果您使用 Visual Studio 2015 创建项目并使用 VS2013 工具集 (v120) 构建它。您需要在 属性 页面上将平台工具集更改为 Visual Studio 2013 (v120)。
当您使用MSBuild命令构建项目时,我们需要将.vcxproj文件中的PlatformToolset更改为V120。 <PlatformToolset>v120</PlatformToolset>
。而我们创建Visual C++项目时默认的平台是Win32:
我注意到在项目文件的相关摘录中,PlatformToolset 已设置为仅适用于 x64 的 v120。
在这种情况下,如果您通过 MSBuild 命令使用默认平台 Win32 构建项目,您将收到该错误:“error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found .
要解决此问题,您需要在 .vcxproj 文件中将 PlatformToolset 更改为 v120 for Win32:
此外,
One possibility is that I installed VS2013 after VS2015 - which is a
bit unusual I suppose. Could that be the issue?
我也在VS2015之后安装了VS2013来重现你的问题,但是在更正PlatformToolset for Win32的值后,MSBuild构建可以成功,没有任何错误。所以这个问题与安装顺序无关,不用担心。
希望对您有所帮助。
我有一台安装了并行 VS2015 和 VS2013 的机器,我正在尝试使用 VS2013 工具集 (v120) 构建一些东西。然而,尽管项目文件中有显式覆盖,它仍在尝试使用 v140。
C:\transfer\MathLib\testSse>msbuild Sse.vcxproj
Microsoft (R) Build Engine version 12.0.40629.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 23-Mar-17 12:35:07.
Project "C:\transfer\MathLib\testSse\Sse.vcxproj" on node 1 (default targets).
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build t
ools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 bui
ld tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-cli
ck the solution, and then selecting "Upgrade Solution...". [C:\transfer\MathLib\testSse\Sse.vcxproj]
Done Building Project "C:\transfer\MathLib\testSse\Sse.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\transfer\MathLib\testSse\Sse.vcxproj" (default target) (1) ->
(PlatformPrepareForBuild target) ->
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build
tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 b
uild tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-c
lick the solution, and then selecting "Upgrade Solution...". [C:\transfer\MathLib\testSse\Sse.vcxpro
j]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.16
C:\transfer\MathLib\testSse>notepad Sse.vcxproj
以下是项目文件的相关摘录:
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
我可以用这个命令覆盖它:
msbuild Sse.vcxproj /p:PlatformTooset=v120
然后编译,但这并没有真正解决问题,因为我在一个大型 Visual Studio 解决方案中有很多这样的东西,我需要它们都使用那个参数。除非我能以某种方式将 msbuild 覆盖参数放入解决方案中。
但是,是什么导致 msbuild
使用我未在任何地方提及的另一个工具集?
一种可能是我在 VS2015
之后安装了 VS2013
- 我想这有点不寻常。这可能是问题所在吗?
并且如果您使用 Visual Studio 2015 创建项目并使用 VS2013 工具集 (v120) 构建它。您需要在 属性 页面上将平台工具集更改为 Visual Studio 2013 (v120)。
当您使用MSBuild命令构建项目时,我们需要将.vcxproj文件中的PlatformToolset更改为V120。 <PlatformToolset>v120</PlatformToolset>
。而我们创建Visual C++项目时默认的平台是Win32:
我注意到在项目文件的相关摘录中,PlatformToolset 已设置为仅适用于 x64 的 v120。 在这种情况下,如果您通过 MSBuild 命令使用默认平台 Win32 构建项目,您将收到该错误:“error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found .
要解决此问题,您需要在 .vcxproj 文件中将 PlatformToolset 更改为 v120 for Win32:
此外,
One possibility is that I installed VS2013 after VS2015 - which is a bit unusual I suppose. Could that be the issue?
我也在VS2015之后安装了VS2013来重现你的问题,但是在更正PlatformToolset for Win32的值后,MSBuild构建可以成功,没有任何错误。所以这个问题与安装顺序无关,不用担心。
希望对您有所帮助。