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

When I run msbuild to build the 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 is located c: \ Program File (x86) \ MSBuild
  • HKLM \ SOFTWARE \ Wow6432Node \ Microsoft \ MSBuild \ ToolVersions \ V4.0 VCTargetsPath set to $ (MSBuildExtensionsPath32) \ Microsoft.Cpp \ v4.0 \
  • when msbuild / verbosity: diag starts, it shows MSBuildExtensionsPath32, MSBuildExtensionsPath64, MSBuildExtensionsPath set as Environment at the beginning of the build as a good system
  • setting MSBuildExtensionsPath32, MSBuildExtensionsPath64, MSBuildExtensionsPath as environment variables in the shell does not cause them to be displayed as the environment when the assembly starts

Attempts to fix

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

It seems that MSBuildExtensionsPath32 is not installing properly, and setting up MSBuildExtensionsPath does not help

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

Please let me know if you have any ideas what is blocking the correct setting of this variable.

+119
msbuild
Apr 18 '13 at 20:10
source share
18 answers

For those who have not completed the forbidden MS protocol (see Xv answer ), you can still fix the problem.

MSBuild uses VCTargetsPath to search for cpp properties by default, but cannot because the registry value does not have this string value.

Check string value

  • Run regedit
  • Navigator HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
  • Inspect VCTargetsPath . Value should = " $(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\ "

Fix

  • Run regedit Navigator with HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
  • Add VCTargetsPath String VCTargetsPath
  • Set the value to " $(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\ "

Note: HKLM means HKEY_LOCAL_MACHINE .

+49
Apr 25 '13 at 18:27
source share

I had this problem when publishing a cocos2d-x application using the command line tool that calls MSBuild. I am using the 64-bit version of Win 7, version VS2013 Express, version cocos2d-x version 3.3 installed by the .NET Framework 4.5.

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

 SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120 
+72
Dec 24 '14 at 3:28
source share

I had the same problem lately, and after installing different packages in a different order, it just got really dirty. Then I found this repo - https://github.com/felixrieseberg/windows-build-tools

npm install --global windows-build-tools

It installs the Python and VS Build tools needed to compile most node modules. It worked!

+26
Jan 03 '17 at 23:22
source share

Installing Microsoft Visual C ++ 2010 Service Pack 1 for the Windows SDK 7.1 compiler fixed the MSB4019 errors that I received on Windows7 x64.

This update indicates the recommended order

  • Visual studio 2010
  • Windows SDK 7.1
  • Visual Studio 2010 SP1
  • Visual C ++ 2010 SP1 Compiler Update for Windows SDK 7.1
+12
Apr 25 '13 at 11:22
source share

For Visual Studio 2017 and 2019 on Windows 10

Many of the answers here relate to older versions of Visual Studio. It worked for me if I used the Visual Studio 2017 community version by setting an environment variable named VCTargetsPath and assigning it a value

 C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets 

If you are using the Visual Studio 2019 community version,

 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160 

Other answers here set this variable to c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140 , but I noticed that in my Visual Studio installation there was no folder named Microsoft.Cpp in my MSBuild folder . So keep that in mind, as well as the fact that the above path refers to the community version of Visual Studio 2017.

Also, make sure that the MSBuild path in the environment variables points to the correct version of MSBuild if you are using the Visual Studio 2017 community version.

 C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin 

If you are using the Visual Studio 2019 community version,

 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin 
+9
Jan 19 '19 at 20:09
source share

On 64-bit systems, MSBuild uses the following properties by default (where C: is SystemDrive):

 MSBuildExtensionsPath = C:\Program Files (x86)\MSBuild MSBuildExtensionsPath32 = C:\Program Files (x86)\MSBuild MSBuildExtensionsPath64 = C:\Program Files\MSBuild 

If this is not the case, it means that you have either set some custom third-party override targets, or your MSBuild installation is corrupted.

What you need to try:

  • Fix .NET installation
  • Apply the latest service pack for Visual Studio
  • Install MSBuildExtensionsPath manually as described above (note the x86 part on 64-bit machines)
+6
Apr 18 '13 at 21:30
source share

I had this problem on the release of Visual Studio 2015. When I used cmake to generate the project, this error appeared.

error MSB4019: The imported project "D: \ Microsoft.Cpp.Default.props" was not found

I fixed this by adding a line

VCTargetsPath

with value

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

in the registry path

HKLM \ SOFTWARE \ Microsoft \ MSBuild \ ToolsVersions \ 14.0

+5
Jul 05 '18 at 11:17
source share

MSBuild is an independent build tool that is often associated with other tools. It may have been installed on your computer with .NET (older versions), Visual Studio (newer versions), or even Team Foundation Build.

MSBuild needs configuration files, compilers, etc. (ToolSet), which correspond to the version of Visual Studio or TFS that will use it, as well as the version of .NET with which the source code will be compiled.

Depending on how MSBuild was installed, the configuration files may be in one or more of these paths.

  • C: \ Program Files (x86) \ MSBuild \ Microsoft.Cpp \ v4.0 \
  • C: \ Program Files (x86) \ MSBuild \ Microsoft.Cpp \ v4.0 \ V120 \
  • C: \ Program Files (x86) \ MSBuild \ Microsoft.Cpp \ v4.0 \ V140 \

As described in other answers, the registry entry and / or environment variable must match the ToolSet path.

  • VCTargetsPath key under HKLM \ SOFTWARE \ Microsoft \ MSBuild \ ToolsVersions \ 4.0
  • The environment variable is VCTargetsPath.

Sometimes an operation like installing a tool leaves an invalid registry setting and / or environment. Other answers - all options for their correction.

The only thing I have to add is an environment variable that does not work for me when I settled on the final \

+3
Jan 22 '17 at 2:05
source share

The registry entries for the MSBuild key worked fine for me. It is important to remember that this should be done for 64-bit or 32-bit branches, depending on which version of MSBuild you are using. I would not recommend using environment variables, as this can cause problems in different versions of MSBuild.

This registry file fixes this in both cases:

 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\MSBuild\ToolsVersions\14.0] "VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V140\\'))" "VCTargetsPath10"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\'))" "VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V110\\'))" "VCTargetsPath12"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V120\\'))" "VCTargetsPath14"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath14)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V140\\'))" [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\MSBuild\ToolsVersions\14.0\10.0] "VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\'))" [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\MSBuild\ToolsVersions\14.0\11.0] "VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V110\\'))" "VCTargetsPath10"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\'))" "VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V110\\'))" [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\MSBuild\ToolsVersions\14.0\12.0] "VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V120\\'))" "VCTargetsPath10"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\'))" "VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V110\\'))" "VCTargetsPath12"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V120\\'))" [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\MSBuild\ToolsVersions\14.0\14.0] "VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V140\\'))" "VCTargetsPath10"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\'))" "VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V110\\'))" "VCTargetsPath12"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V120\\'))" "VCTargetsPath14"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath14)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V140\\'))" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0] "VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V140\\'))" "VCTargetsPath10"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\'))" "VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V110\\'))" "VCTargetsPath12"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V120\\'))" "VCTargetsPath14"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath14)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V140\\'))" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0\10.0] "VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\'))" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0\11.0] "VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V110\\'))" "VCTargetsPath10"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\'))" "VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V110\\'))" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0\12.0] "VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V120\\'))" "VCTargetsPath10"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\'))" "VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V110\\'))" "VCTargetsPath12"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V120\\'))" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0\14.0] "VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V140\\'))" "VCTargetsPath10"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\'))" "VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V110\\'))" "VCTargetsPath12"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V120\\'))" "VCTargetsPath14"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath14)','$(MSBuildExtensionsPath32)\\Microsoft.Cpp\\v4.0\\V140\\'))" 
+3
Aug 17 '18 at 16:23
source share

Nothing else worked for me except setting the path as follows:

 C:\Program Files\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0 
+3
Sep 28 '18 at 13:09 on
source share

Installation Update for Microsoft Visual C ++ 2010 compiler for Windows SDK 7.1 worked for me. However, I had problems updating because I already have VS 2010 and VS 2010 SP1 installed. As Xv mentioned above, the readme.htm file contains solutions for the most common installation problems in the Known Issues section. I will follow the instructions in the readme.htm file and restart your computer after each troubleshooting attempt, as some of them are written to your registry.

+2
May 01 '14 at 18:28
source share

I ran into this error by writing a Build script that would put MSBuild in% PATH% after recursively digging through the C: \ Windows \ Microsoft.NET folder for any MSBuild.exe files found. The last hit found was a catalog that was put on the path. Since the dir command got into the Framework64 folder after the Framework , I got one of the 64-bit MSBuilds installed in my path. I tried to create a Visual Studio 2010 solution and changed the search bar again from C:\Windows\Microsoft.NET to C:\Windows\Microsoft.NET\Framework in order to finish working with 32-bit MSBuild.exe. Now my solution file is building.

0
Nov 09 '15 at 23:41
source share

I just added VCTargetsPath={c:\...} as the environment variable for my Hudson work.

0
Apr 01 '16 at 10:34
source share

For writing, the Microsoft.Cpp.Default.props file can modify env var VCTargetsPath and make the subsequent actions of this var incorrect. I ran into this problem and solved it by setting VCTargetsPath10 and VCTargetsPath11 to the same value as VCTargetsPath .

This must be adapted to the version of VS used.

0
May 29 '17 at 15:12
source share

I see this in VS2017 environment. My script VsDevCmd.bat first calls VsDevCmd.bat , and to solve this problem I installed the VCTargetsPath environment after VsDevCmd and before calling MSBuild:

 set VCTargetsPath=%VCIDEInstallDir%VCTargets 
0
Feb 12 '18 at 19:23
source share

This is due to a mismatch between the installed MSBuild toolkits and registry settings. This can happen if you have completed one or more of the following actions:

  • Install multiple versions of Visual Studio in the wrong order
  • Uninstall one or more versions of Visual Studio
  • Manually make changes or registry changes to install Visual Studio

The only safe and reliable solution is to reinstall your OS. If your project requires multiple versions of Visual Studio, first install the oldest version . Then fix your code so that you can use one tool to build it, otherwise you or your colleagues will be in the same mess again.

If this isnโ€™t an option for you, first read https://stackoverflow.com/a/166608/ for better understanding of the problem and what the various โ€œsolutionsโ€ actually do. Then, depending on the version and configuration of Visual Studio, one of the other answers or their options may help.

A few more tips:

  • Try this answer: stack overflow
0
Oct 11 '18 at 15:15
source share

Adding the answer about VS2017 / 2019 to Chris Gong above (I do not have permission to comment yet).

If the VS 2019 build tools are installed instead of the full version of Visual Studio, the file paths are slightly different. VCTargetsPath must be

 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\ 

Also pay attention to the final backslash - it is required, at least in my case (build tools TFS2017, VS2019). A corresponding change to the PATH entry as well.

0
Aug 12 '19 at 19:31
source share

I ran into the same issue with MSBuild for VS 17

I solved this by applying the following steps:

  • In my case, the Microsoft.Cpp.Default.props file was located in C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets so I created the VCTragetsPath string in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0 with a value of C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets

  • I also made my Jenkins work as administrator

This solved my problem.

0
Aug 14 '19 at 11:47
source share



All Articles