Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild does not contain a value for the "VCTargetsPath" property

I recently installed the Visual Studio 11 Developer Preview to try it out, and now my VS 2010 projects won't open. Instead, I get the following error message:

MSBuild does not contain a value for the "VCTargetsPath" property

I found someone that had reported the issue here on Connect, and the response from Microsoft was:

Posted by Microsoft on 12/2/2011 at 5:25 PM
Hi Afshin,

Thanks for the feedback. The issue you ran into is fixed for the next public release Visual Studio.

Jim Griesmer
Visual C++ Team

Fantastic. So how do I restore VCTargetsPath so my projects will work again?

"VCTargetsPath is a toolset property that is defined in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0. "

I browsed to the VCTargetPath value in the registry and it has the value:

$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\ 

Not sure where to go from here. Any suggestions?

like image 495
superstatic Avatar asked Dec 13 '11 23:12

superstatic


People also ask

What is VCTargetsPath?

Besides, VCTargetsPath is the path of some tools used by MSBuild to compile c++ projects. The default value in VS2019 is C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160 . You can write a custom target in the xxx. vcxproj file to output its value.

How do I use MSBuild EXE?

Use MSBuild at a command prompt To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.


1 Answers

It seems reasonable that the solution Gavin Pugh gave would fix the problem, though I didn't try it. I too ran into this problem after uninstalling the Developer Preview of VS11. I think I know what is really wrong though.

Mladen Jankovic was on the right track. One of the follow two (necessary) registry keys was missing on my machine:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
    • Key Name: VCTargetsPath
    • Type: REG_SZ
    • Value: $(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\
  • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\4.0
    • Key Name: VCTargetsPath
    • Type: REG_SZ
    • Value: $(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\

(You can edit registry keys in Windows by typing enter image description here+R+regedit+Enter)

For me, the second value I listed above was the one that was missing. After I added it, I was able to work with my project again.

like image 112
Jonathan DeCarlo Avatar answered Sep 20 '22 19:09

Jonathan DeCarlo