gpt4 book ai didi

tfs - 在构建服务器上使用 MSBuild 进行构建时,VCTargetsPath 错误

转载 作者:行者123 更新时间:2023-12-02 02:47:04 27 4
gpt4 key购买 nike

在我的 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 文件是独立的。

最佳答案

尝试设置环境变量

VisualStudioVersion=12.0

或者在命令行上将其作为属性显式传递给 msbuild

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

我认为这是因为 Microsoft 试图保持与旧版 Visual Studio 的兼容性。

参见Visual Studio project compatibility and VisualStudioVersion

关于tfs - 在构建服务器上使用 MSBuild 进行构建时,VCTargetsPath 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20076303/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com