在我的C++项目Test.wcxproj中,定义了以下配置:
<?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>然后,我将使用问题导入默认C++属性:
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />当我的构建服务器构建我的MSBuild项目文件(配置是Release,平台是Any CPU)时,我得到了以下错误:
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.MSBuild项目文件的相关部分如下所示:
<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>问题所在
在我的MSBuild项目文件中,我使用ToolsVersion="12.0"。Visual Studio 2013确实安装了,所以我不明白它为什么选择使用v4.0\v110。MSBuild是否出于某种原因跳过了我的项目配置?我想我可以以某种方式使用/p开关覆盖这个文件夹,但是我希望我的.proj文件是独立的。
发布于 2013-12-11 08:43:32
在我的例子中,我的构建定义被配置为构建我的.sln文件而不是.proj文件。我记得将它配置为构建MSBuild项目,但不知怎么的,它似乎已经恢复到解决方案了。
不管怎样,我找到了解决这个问题的两种方法:
.proj文件(其中工具版本确实设置为12.0)。发布于 2014-01-02 09:03:19
尝试设置环境变量
VisualStudioVersion=12.0或将其显式地作为属性传递给命令行上的msbuild。
msbuild.exe <project or solution to build> /p:VisualStudioVersion=12.0我认为这是因为微软试图保持与较老的Visual Studio的兼容性。
https://stackoverflow.com/questions/20076303
复制相似问题