在构建服务器上使用 MSBuild 构建时,VCTargetsPath 是错误的 [英] VCTargetsPath is wrong when building with MSBuild on build server
问题描述
在我的 C++ 项目 Test.wcxproj
中,我定义了以下配置:
In my C++ project, 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>
然后我有默认 C++ 属性的问题导入:
Then I have the problematic import of the default C++ properties:
<Import Project="$(VCTargetsPath)Microsoft.Cpp.Default.props" />
当我的构建服务器构建我的 MSBuild 项目文件时(配置是 Release
,平台是 Any CPU
),我收到这个错误:
When my build server builds my MSBuild project file (configuration is Release
and platform is Any CPU
), I get this error:
error MSB4019: The imported project "C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V110Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
我的 MSBuild
项目文件的相关部分如下所示:
The relevant parts of my MSBuild
project file look like this:
<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.0v110
.MSBuild
是否出于某种原因跳过了我的项目配置?我想我可以使用 /p
开关以某种方式覆盖这个文件夹,但我希望我的 .proj
文件是自包含的.
The problem
In my MSBuild
project file, I am using ToolsVersion="12.0"
. Visual Studio 2013
is indeed installed, so I don't understand why it chooses to use v4.0v110
. Are my project configurations for some reason skipped by MSBuild
? I guess I could somehow override this folder using the /p
switch, but I want my .proj
file to be self-contained.
推荐答案
就我而言,我的构建定义被配置为构建我的 .sln
文件而不是我的 .proj
文件.我记得配置它来构建 MSBuild 项目,但不知何故它似乎已经恢复到解决方案.
In my case, my build definition was configured to build my .sln
file instead of my .proj
file. I remember configuring it to build the MSBuild project, but somehow it seems to have reverted to the Solution.
无论如何,我找到了两个解决问题的方法:
Anyway, I found two solutions to the problem:
- 确保构建
.proj
文件(其中工具版本确实设置为12.0
). - 显式设置VCTargetsPath.
- Make sure to build the
.proj
file (where the tools version is indeed set to12.0
). - Explicitly set the VCTargetsPath.
这篇关于在构建服务器上使用 MSBuild 构建时,VCTargetsPath 是错误的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!