This question has been asked many times, but the previous answers did not help me, or I did something wrong.
Anyway, I have a Visual Studio 2012 solution, which mainly consists of .NET projects, but there are several VC ++ projects that cannot load when I open the solution. Error for each VC ++ project in the "Solution" output:
D: \ folder \ SomeProject.vcxproj: error: cannot read the project file "SomeProject.vcxproj". D: \ folder \ SomeProject.vcxproj (102.3): the imported project "C: \ Microsoft.Cpp.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
The project itself uses the $(VCTargetsPath) macro to resolve this folder, but for some reason it does not work. I tried several solutions, including updating the registry and setting environment variables. The only noticeable change was that I set the VCTargetsPath environment VCTargetsPath to a valid folder, for example C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110 in my case. After rebooting the solution, I got the following result:
D: \ folder \ SomeProject.vcxproj: error: cannot read the project file "SomeProject.vcxproj". D: \ folder \ SomeProject.vcxproj (102.3): The imported project " D : \ Microsoft.Cpp.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
I tried to start VS repair from the control panel, but that did not help. I cannot reinstall Visual Studio at the moment, because I do not have access to the installation files that our company uses. The only workaround I came across builds with MSBuild from the CLI and sets VCTargetsPath there as follows:
$TargetsPath = 'C:\Program%20Files%20(x86)\MSBuild\Microsoft.Cpp\v4.0\v110\' msbuild /v:$Verbosity /m /t:$Target /P:Configuration=$Configuration /P:VCTargetsPath=$TargetsPath /P:TreatWarningsAsErrors=false "$($Solution.FullName)"
And the solution builds just fine. However, I need to load the solution correctly in VS, so this solution only solves some of my problems.
Finally, my question, I think, is how to set or override the VCTargetsPath macro in Visual Studio 2012? Or how do you know where this macro is from? I am using Visual Studio 2012 - version 11.0 Update 5.