简体   繁体   English

MSbuild 错误:找不到 v140 的构建工具(平台工具集 = 'v140')

[英]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的说明。 “):

  1. Launch the "Visual Studio Installer" from your start menu. 从开始菜单启动“Visual Studio Installer”。
  2. Select "Modify" for the instance of Visual Studio 2017 you have installed. 为已安装的Visual Studio 2017实例选择“修改”。
  3. Under the "Summary" pane of the workload selector, click the "Desktop development with C++" expander (if it is collapsed) 在工作负载选择器的“摘要”窗格下,单击“使用C ++进行桌面开发”扩展器(如果已折叠)
  4. Check the "VC++ 2015.3 v140 toolset (x86,x64)" optional feature. 检查“VC ++ 2015.3 v140工具集(x86,x64)”可选功能。

步骤'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.此外,我必须更新环境变量中的以下变量以指向新位置。

  1. 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
  2. VCTargetsPath : C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170 VCTargetsPathC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170
  3. 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.但是我需要这个设置才能工作。

Visual Studio 构建工具 2022

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 步。

image图片

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.

相关问题 node-gyp和contextify-无法找到v140的构建工具(Platform Toolset ='v140') - node-gyp and contextify - The builds tools for v140 (Platform Toolset = 'v140') cannot be found 通过MSBuild构建Visual Studio 2015 C ++项目(v140)失败 - 无法找到v140 - Building Visual Studio 2015 C++ project (v140) by MSBuild Failed - v140 cannot be found 从MSVC V100更新到V140平台工具集时出现C2064编译错误 - c2064 compilation error on updating from msvc v100 to v140 platform toolset Visual Studio 2013错误无法找到MS8020构建工具v140 - Visual Studio 2013 error MS8020 Build tools v140 cannot be found 从v100调用时在平台工具集v140 DLL上写入访问冲突 - Access violation writing on platform toolset v140 DLL when call from v100 Platform Toolsets v140和v140_xp之间有什么区别? - What's the difference between Platform Toolsets v140 and v140_xp? 如何在Windows 7上将DirectX 11与Visual Studio 2015工具集v140一起使用 - How to use DirectX 11 with Visual Studio 2015 toolset v140 on Windows 7 Visual Studio 2015:v120 与 v140? - Visual Studio 2015: v120 vs v140? 是否可以在visual studio 2013中安装v140构建工具?如果是的话怎么样? - is it possible to install v140 build tools in visual studio 2013? if yes then how? Visual Studio 2015 构建工具/CPP 运行时 v140 Dockerfile 无法正常工作 - Visual Studio 2015 Build Tools / CPP Runtime v140 Dockerfile isn't working correctly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM