3
votes

I try to compile a .NET 4.6 C# project on my build machine using only MSBuild. I did not install the Visual Studio 2015 on the machine, but just the following:

  • .NET Framework 4.6 Runtime
  • .NET Framework Targeting Pack
  • Microsoft Build Tools 2015

I run following in the cmd: "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" MySolution.sln

The error I get is:

"error MSB4019: The imported project "C:\Microsoft.Cpp.Defaults.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk."

I have already checked that the "Microsoft.Cpp.Defaults.props" file exists in "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0", but not in the "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140". Actually even the folder "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140" does not exist.

What more should I do/install to compile this?

1
It's probably the case that "the path in the declaration" is incorrect, since the pathname given in the error message puts the file in the root directory of the C: drive.Ross Ridge
Please try uninstalling and reinstalling the build tools. Seems this should fix this. The default path is not properly set that cause the error.staticvoidmain
I reinstalled the Build Tools, even installed them on the other machine and still there is the same error...Bartłomiej Kania

1 Answers

2
votes

I had same problem. I fixed it by adding below argument when run ms build.

/p:VisualStudioVersion=12.0

Not 14.0.

I refered this answer.

External VS2013 build error "error MSB4019: The imported project <path> was not found"