20

We've installed the Microsoft Build Tools 2013, from http://www.microsoft.com/en-us/download/details.aspx?id=40760, but after installation, there is no C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120 directory created, and so it cannot find required targets files.

Do we really need to install a version of VS2013 for the required targets/props files to be created?

Richard Anthony Hein
  • 10,550
  • 3
  • 42
  • 62
  • 1
    Yeah, pretty unlikely you'll get the C++ build targets with that. – Hans Passant Nov 11 '13 at 22:05
  • @HansPassant Thanks ... so I guess there's no option other than to install VS on the build server or copy over all the targets and create the registry keys manually. Let me know if there's another, better, option. – Richard Anthony Hein Nov 12 '13 at 15:03
  • This is software that's protected by copyright and is not distributable. Ask your corporate counsel what the correct option looks like, you'll get a plain and unequivocal answer. – Hans Passant Nov 12 '13 at 15:09
  • @HansPassant Fair enough. I obviously misunderstood the point of Build Tools 2013. I just re-read the description, "If you don't have Visual Studio installed on your computer, you can use Build Tools 2013 to build managed applications." it's obviously only intended to build managed applications without VS. Thanks Hans. – Richard Anthony Hein Nov 12 '13 at 15:29
  • 2
    Actually I have the same problem with C# projects. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0 was missing after MSBuild tools install and I was unable to build a .sln containing managed projects (all .csproj's) because of missing .targets. It builds without problems when I copy this directory from my dev machine (which has visual studio installed). – Ilan Mar 04 '14 at 12:56
  • 3
    Richard you're right, but unfortunately the download page for Microsoft Build Tools 2013 explicit says that it includes compiler for C# and Visual Basic. Hence, C++ compiler is not included, I'm afraid. I would ask Microsoft to complete the download bundle with the missing compilers, since on my PC I still can't build... :( – jeanie77 Jun 15 '17 at 10:49

2 Answers2

23

The answer is yes, you need to install VS2013. Then add a new string value named VCTargetsPath12 to

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\12.0\11.0

The value should be:

$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V120\'))

You also need to change the

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\12.0\11.0\VCTargetsPath

value to:

$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V120\'))

If you continue to have problems with some projects, open the .vcxproj file and make sure the Project element's ToolsVersion attribute is set to 12.0 instead of 4.0. Do the same for the .vcxproj.filters.

If you get some "SetEnv" related errors just rebuild those projects that failed.

Verified on multiple machines to work.

Igal Tabachnik
  • 31,174
  • 15
  • 92
  • 157
Richard Anthony Hein
  • 10,550
  • 3
  • 42
  • 62
  • 1
    I wasted half a day reinstalling Visual Studio 2013 (did not resolve the issue). And after much searching on msbuild I finally found your answer. Much appreciated. – MW_dev Sep 05 '14 at 01:17
  • @Coda This one was totally torture. Glad to have been some help. :) – Richard Anthony Hein Sep 08 '14 at 16:27
  • On a fresh Win7 x64 machine I installed the **.Net4.5.1** and then **[Microsoft Build tools 2013][1]**
    I have a VS2013 C++ project with complete sources and files. When I try to compile the VS2103 project with the msbuild.exe it is failing with error below error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. What else do I need to install on the Win7 x64 machine to get it working ? [1]: http://www.microsoft.com/en-in/download/details.aspx?id=40760
    – proton Dec 08 '14 at 10:36
  • Maybe some VCTargetsPath[XX] keys are missing in the registry. Those keys are located in [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\12.0] : **"VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V120\\'))"** **"VCTargetsPath12"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V120\\'))"** – Mohamed BOUZIDI Aug 15 '17 at 13:53
3

NOTE: Weirdly this did only work for debug configuration. There seems to be missing some parts afterall. I ended up installing VS2013 express.

If you are ok with having Visual Stuido 2015 installed you can either change your VS2015 current isntallation or newly install it. From the 2015 installer, select Windows 8.1 and Windows Phone 8.0/8.1 Tools and common Tools for Visual C++ 2015:

enter image description here

After installation completed, you will find the platform Toolset below (in my case VS2017):

enter image description here

Credits: https://stackoverflow.com/a/42687137/4870255

Sebastian Ax
  • 1,240
  • 12
  • 11