VCTargetsPath error while creating using MSBuild on build server

In my C ++ Test.wcxproj , I have the following configurations defined:

 <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Debug|x64"> <Configuration>Debug</Configuration> <Platform>x64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> </ItemGroup> 

Then I have a problematic import of C ++ properties by default:

 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> 

When my build server builds my MSBuild project file ( Release configuration and Any CPU platform), I get this error:

 error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. 

The relevant parts of my MSBuild project project are as follows:

 <ItemGroup> <ProjectFiles Include="$(MSBuildProjectDirectory)\**\*.csproj" /> <ProjectFiles Include="$(MSBuildProjectDirectory)\**\*.vcxproj" /> </ItemGroup> <PropertyGroup> <Configuration>Release</Configuration> <Platform>x64</Platform> <OutputFolder>$(MSBuildProjectDirectory)\BuildOutput\$(Configuration)</OutputFolder> <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)</SolutionDir> </PropertyGroup> ... <Target Name="Compile"> <MSBuild Projects="@(ProjectFiles)" Targets="Build" Properties="Configuration=$(Configuration);Platform=$(Platform);OutputPath=$(OutputFolder)\$(MSBuildProjectName);SolutionDir=$(SolutionDir)\" /> </Target> 

Problem

In my MSBuild project file, I use ToolsVersion="12.0" . Visual Studio 2013 really installed, so I don’t understand why it chooses to use v4.0\v110 . Are my project configurations missing for some reason on MSBuild ? I think I could somehow override this folder with the /p switch, but I want my .proj file .proj be offline.

+7
tfs visual-studio-2013 msbuild
source share
2 answers

In my case, my build definition was set to collect my .sln file instead of my .proj file. I remember how he set it up to create an MSBuild project, but somehow it seems to be back to the solution.

In any case, I found two solutions to the problem:

  • Be sure to create a .proj file (where the version of the tools is really set to 12.0 ).
  • Explicitly set the VCTargetsPath .
+2
source share

Try setting environment variable

 VisualStudioVersion=12.0 

or pass it explicitly as a msbuild property on the command line

 msbuild.exe <project or solution to build> /p:VisualStudioVersion=12.0 

I think this is because Microsoft is trying to maintain compatibility with older Visual Studios.

see compatibility of Visual Studio and VisualStudioVersion projects

+7
source share

All Articles