Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"C:\Microsoft.Cpp.Default.props" was not found

I have a project created in Visual Studio, 2013.

The project file has the following properties:

ToolsVersion="12.0", PlatformToolset = v120.

I have Visual Studio 2013 and Microsoft Build Tools 2015 installed. This project gets successfully built using MSBuild 12.0. Upon the attempt to build it with MSBuild 14.0 I get an 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. 

As I understand, the problem is that the variable VCTargetsPath doesn’t get evaluated. If I specify the variable VCTargetsPath before the build (with the value C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120), the problem is solved.

However, this approach is not very convenient in case the path is different. Is it possible to somehow solve the problem in a more optimal way?

The registry key and its value:

HKLM\Software\WOW6432Node\Microsoft\MSBuild\ToolsVersions\12.0\VCTargetsPath $([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V120\'))
like image 749
Serg Avatar asked Jan 17 '17 10:01

Serg


People also ask

Where to find Microsoft Cpp default props?

Cpp. Default. props" exists in only in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets".

Where is VCTargetsPath defined?

Actually, VCTargetsPath property is defined in the MSBuild system props or targets files under MSBuild folder( C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild ).


3 Answers

It took me two hours to fix this problem, but I finally finished.

The following solved my problem:

  1. Run this on an elevated command prompt (admin): npm install --global --production windows-build-tools. If you don't have npm I recommend installing it, otherwise this won't work.
  2. Change ownership in the install dir (in my case C:\Program Files (x86)\MSBuild\14.0) to your user, instead of admin. (properties>Security>Advanced).
like image 149
Nic Szerman Avatar answered Sep 20 '22 21:09

Nic Szerman


I recently reinstalled Visual studio 2017 and encountered this issue while trying to install "npm java". The fix for me is:

  1. set ms version to 2017: npm config set msvs_version 2017
  2. set VCTargetsPath environment variable to C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets
  3. run command console as system administrator
like image 22
Alex Avatar answered Sep 21 '22 21:09

Alex


These steps solved my issue:

  1. Run npm install --global --production windows-build-tools
  2. Run npm install --save nan
  3. Set VCTargetsPath environment variable to C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140
like image 22
Emre Tapcı Avatar answered Sep 22 '22 21:09

Emre Tapcı