首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在生成服务器上使用VCTargetsPath构建MSBuild是错误的

在生成服务器上使用VCTargetsPath构建MSBuild是错误的
EN

Stack Overflow用户
提问于 2013-11-19 16:03:01
回答 2查看 35.3K关注 0票数 10

在我的C++项目Test.wcxproj中,定义了以下配置:

代码语言:javascript
复制
<?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++属性:

代码语言:javascript
复制
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

当我的构建服务器构建我的MSBuild项目文件(配置是Release,平台是Any CPU)时,我得到了以下错误:

代码语言:javascript
复制
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项目文件的相关部分如下所示:

代码语言:javascript
复制
<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\v110MSBuild是否出于某种原因跳过了我的项目配置?我想我可以以某种方式使用/p开关覆盖这个文件夹,但是我希望我的.proj文件是独立的。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-12-11 08:43:32

在我的例子中,我的构建定义被配置为构建我的.sln文件而不是.proj文件。我记得将它配置为构建MSBuild项目,但不知怎么的,它似乎已经恢复到解决方案了。

不管怎样,我找到了解决这个问题的两种方法:

  1. 确保构建.proj文件(其中工具版本确实设置为12.0)。
  2. 显式设置VCTargetsPath
票数 3
EN

Stack Overflow用户

发布于 2014-01-02 09:03:19

尝试设置环境变量

代码语言:javascript
复制
VisualStudioVersion=12.0

或将其显式地作为属性传递给命令行上的msbuild。

代码语言:javascript
复制
msbuild.exe <project or solution to build> /p:VisualStudioVersion=12.0

我认为这是因为微软试图保持与较老的Visual Studio的兼容性。

请参阅Visual项目兼容性和VisualStudioVersion

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20076303

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档