25

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.

Arash
  • 271
  • 1
  • 4
  • 5
  • Possible duplicate of [Is it possible to have projects with different Platform Toolset in a solution? (MSBuild)](http://stackoverflow.com/questions/33576552/is-it-possible-to-have-projects-with-different-platform-toolset-in-a-solution) – stijn Nov 10 '15 at 20:50

8 Answers8

61

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

Jacob Nelson
  • 2,370
  • 23
  • 35
  • Big note for anyone confused why the steps in the image are not working. Step 4 is the important one, and not depicted im the image. Also see here for the image: https://developercommunity.visualstudio.com/content/problem/48806/cant-find-v140-in-visual-studio-2017.html as described by the Visual studio website itself. - OR just type 140 in the search box at the top. – T.S Mar 18 '20 at 17:29
  • 1
    I didn't find the "VC++ 2015.3 v140 toolset (x86,x64)", nor didn't have search box to search. You can go to the "Individual Components" and search manually, it should be under the category: "Compilers, build tools, and runtimes" – E235 Oct 21 '20 at 06:24
7

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

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
4

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.

h-rai
  • 3,636
  • 6
  • 52
  • 76
2

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

Algorithmic
  • 138
  • 12
2

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.

NOTE: The paths may change depending on the version of VS installed, for example if you're using VS 2022 64bit Professional the variables may look like:

  1. PATH: C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin
  2. VCTargetsPath: C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\

Visual Studio Build Tools 2022

rboy
  • 2,018
  • 1
  • 23
  • 35
user007
  • 1,504
  • 2
  • 18
  • 51
  • I did install the v140 component but VS2022 still complains that it can't find the VS2015 (V140) platform toolset in the project settings. Where did you fix the variables? Through VS settings, the Command Environment or Registry? – rboy Feb 26 '23 at 20:00
  • I added the Environment variables in `Control Panel > System > Edit Environment Variables` – user007 Feb 27 '23 at 16:56
  • Thanks, tried that (With VS2022 x64 professional the paths are slightly different) but it's still giving me error when I try to build it `MSB8020 The build tools for 'v140' application Type UWP (Platform Toolset = 'Visual Studio 2015') cannot be found. Please install the workflow for this application type and include the build tools for the C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets 443`. Any thoughts? – rboy Mar 01 '23 at 17:54
  • Can you confirm that file is existing in your VCTargetsPath folder? I have updated my new file path and I will edit the answer with it. My current values in my new laptop are below: Path: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin VS140COMNTOOLS: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools VCTargetsPath: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170 – user007 Mar 01 '23 at 19:54
2

If you are using Visual Studio 2022 Build Tools, then the following PowerShell script will fix it:

$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.

Bassem Ramzy
  • 326
  • 3
  • 10
  • thank you for this copypasta answer. for my use case, an old windows 7 box was unable to make the request due to being set to tls v1.0 by default and the server requiring tls v1.2 so from what i can gather the copypasta from the the following SO answer allowed this pasta to work https://stackoverflow.com/a/66614041/708807 – ipatch Feb 20 '23 at 21:17
0

Jacob's answer worked for me, but I had to click on the "Individual components" tab at the top for my Step 3.

image

-2

This solution worked perfectly for me: https://social.msdn.microsoft.com/Forums/vstudio/en-US/e0b9c601-2ece-4dcc-bac3-23ed7dd6801a/the-builds-tools-for-v120-platform-toolset-v120-cannot-be-found?forum=vclanguage

  • 5
    Welcome to Stack Overflow! It's important for an answer to include the information needed to solve the problem -- posting a hyperlink is fine but it isn't enough by itself (since the linked page may eventually disappear). – jkdev May 25 '16 at 01:44