-1

I'm trying to run the main function of a c++ library of mine but it doesn't wanna work. Returning as error:

The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" is correct and that the file exists on disk.

However, when I look at some of the solutions for this problem they seem to suggest I have to change the value of my VCTargetsPath too $(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0. My question is what exactly is the value of MSBuildExtensionsPath32. Also what else do I need to do to be able to solve this issue?

Sometimes I also get a failure to build with no error output. I don't know if the MBS4019 error is related to this issue as well?enter image description here

The release is Win32.

PeterQuando
  • 75
  • 1
  • 7
  • Did you check on what the first error message told you? What I mean is does the mentioned file exist? I just checked and I I have that file on my system and Visual Studio 2019 Community – drescherjm Dec 21 '20 at 21:03
  • @drescherjm And what is the "path" if I may ask? Because I can't find it. – PeterQuando Dec 21 '20 at 21:10
  • If looking in explorer and that path doesn't show it is probably because you don't have the "Show hidden files, folders and drives" option selected in the View tab of "File explorer options" (that latter is something you can type into the windows search bar and get the dialog in question). – SoronelHaetir Dec 21 '20 at 21:18
  • For me the file is exactly in this folder: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160` although there was a v150 folder as well in the parent folder. – drescherjm Dec 21 '20 at 21:20

1 Answers1

0

You should first check whether you have the file Microsoft.Cpp.Default.props under C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\ on your C disk. That file works for v142 platform toolset.

And from the message, your project uses the file under C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props. That is the correct path for v142 toolset(VC++ 2019 build tool).

If VS find v142 toolset from a different path, it means that your VS has some errors which cannot find the right path and uses the wrong path. In this case, you should use VCTargetsPath and MSBuildExtensionsPath32. Here is an issue in this situation.

I think your issue is that your Microsoft.Cpp.Default.props file is missing on your current PC. And VC++ cannot find that file so that it leads the error. Not sure whether you have deleted the file manually or the file is deleted by some three party programs.

To solve it, you should repair VS from vs_installer.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41