Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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#). 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). 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:

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. To build using the v140 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install v140 to build using the v140 build tools.

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.

Any help would be very appreciated.

like image 454
Arash Avatar asked Oct 15 '15 17:10

Arash


People also ask

How install v140 Build tools?

To build using the v140 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install v140 to build using the v140 build tools.

How to change Platform Toolset in visual studio 2019?

To change the platform toolset In Visual Studio, on the menu bar, select Project > Properties to open your project Property Pages dialog box. In the top of the Property Pages dialog box, open the Configuration drop-down list and then select All Configurations.


5 Answers

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.'):

  1. Launch the "Visual Studio Installer" from your start menu.
  2. Select "Modify" for the instance of Visual Studio 2017 you have installed.
  3. Under the "Summary" pane of the workload selector, click the "Desktop development with C++" expander (if it is collapsed)
  4. Check the "VC++ 2015.3 v140 toolset (x86,x64)" optional feature.

illustration of steps '3.' and '4.'

like image 126
Jacob Nelson Avatar answered Oct 03 '22 05:10

Jacob Nelson


The builds tools for v140 that's the platform toolset for 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. You should install VS2015 on your build machine.

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. For the details, check: TFS 2013 building .NET 4.6 / C# 6.0

like image 37
PatrickLu-MSFT Avatar answered Oct 03 '22 04:10

PatrickLu-MSFT


Jacob's answer worked for me but C++ build tools were under VS Build Tools 2017 while I had VS 2019 Installer on Windows 10 as at July, 2019.

like image 44
h-rai Avatar answered Oct 03 '22 05:10

h-rai


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

like image 38
Algorithmic Avatar answered Oct 03 '22 04:10

Algorithmic


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. 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
  2. VCTargetsPath: C:\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. But this setting was needed for me to work.

Visual Studio Build Tools 2022

like image 35
user007 Avatar answered Oct 03 '22 05:10

user007