[英]MSbuild Error: The builds tools for v140 (Platform Toolset = 'v140') cannot be found
I have a solution which is consists of a large number of projects (C++ and C#).我有一个由大量项目(C++ 和 C#)组成的解决方案。 I upgraded the solution to VS2015, so the toolset version for most of them are now set to V140, but a small number of projects need to remain in V110 (third party libraries, etc).
我将解决方案升级到了VS2015,所以大部分的工具集版本现在设置为V140,但有一小部分项目需要保留在V110(第三方库等)。 When I build the solution in Visual Studio 2015, it builds just fine, but when TeamFoundationServer tries to build it, it fails with the following error:
当我在 Visual Studio 2015 中构建解决方案时,它构建得很好,但是当 TeamFoundationServer 尝试构建它时,它失败并出现以下错误:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets (44): The builds tools for v140 (Platform Toolset = 'v140') cannot be found. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets (44):找不到 v140 的构建工具(平台工具集 = 'v140')。 To build using the v140 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...".
要使用 v140 构建工具进行构建,请单击“项目”菜单或右键单击解决方案,然后单击 select“更新 VC++ 项目...”。 Install v140 to build using the v140 build tools.
安装 v140 以使用 v140 构建工具进行构建。
I tried to specify the VisualStudioVersion or the path to the right MSBuild version as build arguments, but it didn't work as the rest of the projects (the ones in V110) will be in trouble.我试图将 VisualStudioVersion 或正确的 MSBuild 版本的路径指定为构建 arguments,但它不起作用,因为项目(V110 中的项目)的 rest 会遇到麻烦。
Any help would be very appreciated.任何帮助将不胜感激。
I had the same issue. 我遇到过同样的问题。 Steps given in this Solution helped me solve my issue.
此解决方案中给出的步骤帮助我解决了我的问题。 Repeating the steps here for future reference.
重复此处的步骤以供将来参考。
If you're attempting to build a Win32 "Desktop" application, the easiest way to get the v140 Platform Toolset is via the Visual Studio Installer (please see the image, below, for an illustration of steps '3.' and '4.'): 如果您正在尝试构建Win32“桌面”应用程序,获取v140平台工具集的最简单方法是通过Visual Studio安装程序(请参阅下面的图像,以获取步骤'3'和'4的说明。 “):
The builds tools for v140 that's the platform toolset for VS2015. v140的构建工具是VS2015的平台工具集。
If you are using TFS2015, you must make sure the build environment on your build machine be the same as your local developer machine. 如果您使用的是TFS2015,则必须确保构建计算机上的构建环境与本地开发人员计算机相同。 You should install VS2015 on your build machine.
您应该在构建计算机上安装VS2015。
If you are using TFS2013 or TFS2012, most probably MSBuild 12.0 is called.You need to set the build templates to point to MS Build version 14.0. 如果您使用的是TFS2013或TFS2012,则最有可能调用MSBuild 12.0。您需要将构建模板设置为指向MS Build版本14.0。 For the details, check: TFS 2013 building .NET 4.6 / C# 6.0
有关详细信息,请查看: TFS 2013构建.NET 4.6 / C#6.0
You're trying to build using a different version of the build toolset that is either not installed on your system or that the project can't use. 您正在尝试使用未在系统上安装或项目无法使用的不同版本的构建工具集进行构建。 To change it to something that you have installed on your system, right click on the project in your Solution Explorer.
要将其更改为系统上已安装的内容,请在解决方案资源管理器中右键单击该项目。
Go to Properties. 转到“属性”。 Configuration Properties>General>Platform Toolset>(Change this to a toolset that is installed on your system).
配置属性>常规>平台工具集>(将其更改为系统上安装的工具集)。 Make sure you do this for the Debug and Release builds
确保为Debug和Release版本执行此操作
雅各布的回答对我有用,但是在2017年7月我在Windows 10上使用VS 2019安装程序时,C ++构建工具属于VS Build Tools 2017。
For the folks who are trying to do the same with Visual Studio Build Tools 2022
, you may find this under Optional
when choosing Desktop development with C++
Workload.对于试图使用
Visual Studio Build Tools 2022
进行同样操作的人们,您在选择Desktop development with C++
Workload在Optional
台式机开发时可能会发现这一点。 Also, I had to update below variables in Environment variables to point to the new location.此外,我必须更新环境变量中的以下变量以指向新位置。
Path
: replace previous path for BuildTools with C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin
Path
:将 BuildTools 的先前路径替换为C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin
VCTargetsPath
: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170
VCTargetsPath
: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170
VS140COMNTOOLS
: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
PS: I didn't have to change the value. VS140COMNTOOLS
: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
PS:我不必更改该值。 But this setting was needed for me to work. Jacob's answer worked for me, but I had to click on the "Individual components" tab at the top for my Step 3. Jacob 的回答对我有用,但我必须单击顶部的“单个组件”选项卡才能执行第 3 步。
If you are using Visual Studio 2022 Build Tools , then the following PowerShell script will fix it:如果您使用的是Visual Studio 2022 Build Tools ,则以下 PowerShell 脚本将修复它:
$VS_BTOOLS_EXE="vs_buildtools.exe"
$VS_BTOOLS_URI="https://aka.ms/vs/17/release/vs_buildtools.exe"
Invoke-WebRequest -Uri $VS_BTOOLS_URI -OutFile $VS_BTOOLS_EXE
Start-Process -FilePath ./vs_BuildTools.exe -ArgumentList `
"--add", "Microsoft.VisualStudio.Component.VC.140", `
"--quiet", "--norestart", "--force", "--wait" -Wait -PassThru
Useful when silent installation is needed as well.当还需要静默安装时很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.