Why does MSBuild look in C:\ for Microsoft.Cpp.Default.props instead of c:\Program Files (x86)\MSBuild? ( error MSB4019)

msbuild

When I run msbuild to build a vc2010 project I get the following error:

error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. 
Confirm that the path in the <Import> declaration is correct, and that the file exists 
on disk.
  • msbuild located c:\Program File (x86)\MSBuild
  • HKLM\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolVersions\V4.0 VCTargetsPath set to $(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\
  • when running msbuild /verbosity:diag as good system shows MSBuildExtensionsPath32, MSBuildExtensionsPath64, MSBuildExtensionsPath set as Environment at start of build
  • setting MSBuildExtensionsPath32, MSBuildExtensionsPath64, MSBuildExtensionsPath set as environment variables in shell doesn't cause them to show as Environment at start of build

Fixes Attempted

  • Uninstalled .net 4.5, repaired .net 4.0
  • Set MSBuildExtensionsPath32, MSBuildExtensionsPath64, MSBuildExtensionsPath in system variables.

It appears that MSBuildExtensionsPath32 isn't being set properly and setting MSBuildExtensionsPath doesn't help

SET MSBuildExtensionsPath="C:\Program Files\MSBuild"

Please let me know if you have any ideas what's blocking the proper setting of this variable.

Best Answer

I got this problem when publishing a cocos2d-x application using their command line tool, which calls MSBuild. I'm using Win 7 64-bit, VS2013 express, cocos2d-x version 3.3, .NET Framework 4.5 installed.

I fixed the problem by setting the following before running the cocos.py publish command:

SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120
Related Topic