【问题标题】:Is OutputPath a required field in every PropertyGroup?OutputPath 是每个 PropertyGroup 中的必填字段吗?
【发布时间】:2012-04-25 20:03:26
【问题描述】:

我的项目似乎都有三个 <PropertyGroup> 项目。

一个:

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

两个:&lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "&gt;
三:&lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "&gt;

FinalBuilder 一直失败。当我进入项目文件并将&lt;OutputPath&gt;bin\Debug\&lt;/OutputPath&gt; 添加到 .csproj 文件(我理解的 MSBuild 文件)的第一个元素时,构建成功。

其余两个元素已经定义了&lt;OutputPath&gt;

这是所有三个元素的必填字段吗?为什么我的项目文件的第一个元素中缺少它?

【问题讨论】:

    标签: visual-studio-2010 msbuild finalbuilder


    【解决方案1】:

    当 MSBuild 编译项目时,它会将 OutputPath 作为参数,用于放置构建输出的位置。

    .csproj 文件有一些默认 设置。它在第一个 中。

    在条件PropertyGroups 中有具体的属性,针对不同的配置和平台:

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    

    此节点内的属性会覆盖默认属性,因此它可以专门化构建。

    要点击不同的PropertyGroups,MSBuild 需要一些参数,例如点击“Release|x86”,命令如下所示:

    msbuild /p:Configuration="Release" /p:Platform="x86" 
    

    MSBuild 将使用默认PropertyGroup 中的属性,并覆盖/使用PropertyGroups 中满足条件的属性,在本例中为“Release|x86”来编译代码。

    您的问题听起来像 MSBuild 没有正确的参数来评估正确的 PropertyGroups。

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 2020-02-04
      • 2020-09-02
      • 1970-01-01
      • 1970-01-01
      • 2014-06-25
      • 2017-06-28
      • 2015-02-26
      • 1970-01-01
      相关资源
      最近更新 更多