MSBuild does not contain a value for the "VCTargetsPath" property
Asked Answered
U

10

60

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?

Unnecessarily answered 13/12, 2011 at 23:54 Comment(4)
These preview editions are less than alpha quality. Never install anything but RTM on a production machine unless you use a VM. Repair VS2010, reinstall next.Suppletory
This happens with the Customer Preview too, not just those "pre-pre-alphas" you mention.Schertz
Possible duplicate of Why does MSBuild look in C:\ for Microsoft.Cpp.Default.props instead of c:\Program Files (x86)\MSBuild? ( error MSB4019)Hulse
Broke in latest version of Visual Studio 2017. Apparently it thinks the path is "C:\". Impossible to build libssh2.Leandroleaning
D
82

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.

Delusion answered 16/2, 2012 at 1:36 Comment(3)
Worked for me too. The second key (Wow6432Node) was missing after unstall of VS11 CTP on x64 system.Poseur
There was VCTargetsPath in the env variables and found it last when there was nothing to try.Sixteenmo
I had same issue with VS2017. For VS2017 the correct value to set in registry is $(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\v140\Bonnie
R
7

Here's the thing that did trick for me:

Change registry value named DefaultToolsVersion located in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\4.0 from 2.0 to 4.0. Do the same thing in Wow6432Node too.

Rampant answered 2/1, 2012 at 4:9 Comment(0)
S
4

The registry editing method suggested by "Mladen Jankovic" didn't work for me.

I just ran a repair on Visual Studio 2010 (run the setup.exe on the VS2010 install disc, or invoke the 'uninstall' via Control Panel->Programs). It did the trick for me.

You also should run the SP1 install again.

For what it's worth, my 'add-ins' (including Incredibuild) behaved fine after this. They didn't need to be reinstalled or repaired. My settings/window/debugger placement also was retained.

Apparently this issue only presents itself if you uninstall the Developer Preview of VS11: http://www.gamefromscratch.com/post/2011/12/15/Do-not-remove-Visual-Studio-2011-developer-preview!.aspx

Sideburns answered 5/1, 2012 at 1:25 Comment(0)
L
4

For those who are here by google search :

If you had previously installed VS 2015 or any later versions of vs after vs2010, and then uninstalled, Here is the solution for you.

In the error message below :

Cannot evaluate the property expression "$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V140\'))"

14.0 is the version number of VS2015. Unfortunately, the VS2015/2012 uninstaller forgets one of its registry keys, which then causes that error when you go back to VS2010.

Go to start/run/ regedit >

Look for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0 (12.0 as well)

And

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\14.0 (12.0 as well )

If there is a key 14.0/12.0 here, delete it and your VS2010 will hopefully work again.

Loats answered 21/7, 2016 at 11:50 Comment(2)
This did indeed fix it for me, but there is one problem: I uninstalled VS2015 because of a problem with the VS2015 installation, but then reinstalled it again, because I need it. So this solution might fix VS2012 but break VS2015.Hulse
For a somewhat better understanding of the problem, see also https://mcmap.net/q/161371/-why-does-msbuild-look-in-c-for-microsoft-cpp-default-props-instead-of-c-program-files-x86-msbuild-error-msb4019Hulse
E
1

Ugh I finally found the answer for this, which incidentally didn't give me the same error message - I get:

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.

For some reason it worked fine with 32-bit builds, but not 64-bit builds.

Anyway, the solution is to copy all the VCTargetPath* keys from HKLM\SOFTWARE\Wow6432Node\Microsoft\MSBuild ToolsVersions\14.0 to HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0. They were missing for me.

Actually I only copied VCTargetsPath and VCTargestPath14 because copying is quite tedious. Seems to be sufficient for VC++ 2015.

Electrotherapy answered 28/6, 2017 at 11:11 Comment(0)
O
0

If working with VS 2010 SP1, go to Control Panel | Uninstall a program, Uninstall/Change the VS 2010 SP1 and pick reapply SP1. It worked for me.

Openhearted answered 28/3, 2012 at 8:40 Comment(0)
C
0

I've been having this same issue, and found out that the toolset tag was not set in the project node

Setting the tools version solved it for me

Cambrai answered 6/3, 2013 at 18:40 Comment(2)
How did you set the tools version?Dominus
This solved the problem for me. @limelights, you can set the tools version in the project properties. In the property pages, look under Configuration Properties > General > Platform Toolset. You can also do this in your favorite text editor, but you need to know the values.Burrell
T
0

I used C:\Windows\SysWOW64\regedit.exe and went to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\3.5 and in the folder for version 3.5 it had 2.0 listed in the defaulttoolsversion so I modified that to 3.5 and everything works now.

Teachin answered 26/11, 2015 at 1:52 Comment(0)
S
0

I arrived here when trying to build a c++ project without the c++ Visual Studio build tools installed. My solution was to download the Visual Studio Build Tools installer from the downloads page under 'Tools for Visual Studio 2017' tab, running the installer with the"Visual C++ build tools" and ".NET Desktop Build Tools" options.

Sexagenarian answered 21/8, 2018 at 21:17 Comment(0)
S
0

I also suffered from the missing registry values under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0.

Adding the missing entries with the following commands fixed it.

REG ADD HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0 /v VCTargetsPath /t REG_SZ /d '$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\14.0@VCTargetsPath)'
REG ADD HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0 /v VCTargetsPath14 /t REG_SZ /d '$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\14.0@VCTargetsPath14)'
Stillman answered 14/7, 2020 at 21:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.