【问题标题】:Change a reference path based on the build target根据构建目标更改引用路径
【发布时间】:2011-07-26 18:59:10
【问题描述】:

我有一个需要一些外部依赖项的单元测试项目。这些依赖有两种形式:i386 (........\External\EA\i386\Core.dll) 和 amd64 (........\External\EA\amd64\Core.dll) .

  <ItemGroup>
    <Reference Include="Core">
      <HintPath>..\..\..\..\External\EA\amd64\Core.dll</HintPath>
    </Reference>
    <Reference Include="Util">
      <HintPath>..\..\..\..\External\EA\amd64\Util.dll</HintPath>
    </Reference>

MsTest 是 32 位,我希望这些程序集的路径是 ........\External\EA**i386**\Core.dll。换句话说,我如何告诉 msbuild 选择正确的构建目标。

谢谢

【问题讨论】:

标签: msbuild


【解决方案1】:

只需在引用上设置一个条件,或者如下所示,在包含它们的 ItemGroup 上,

<ItemGroup
   Condition="'$(Platform)' == 'x64'">
   <Reference Include="Core">
      <HintPath>..\..\..\..\External\EA\amd64\Core.dll</HintPath>
   </Reference>
   <Reference Include="Util">
      <HintPath>..\..\..\..\External\EA\amd64\Util.dll</HintPath>
   </Reference>
</ItemGroup>
<ItemGroup
   Condition="'$(Platform)' == 'Win32'">
   <Reference Include="Core">
      <HintPath>..\..\..\..\External\EA\i386\Core.dll</HintPath>
   </Reference>
   <Reference Include="Util">
      <HintPath>..\..\..\..\External\EA\i386\Util.dll</HintPath>
   </Reference>
</ItemGroup>

您必须准确了解您的项目使用的 $(Platform) 值,对项目的 XML 进行简单检查即可显示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 2021-08-17
    相关资源
    最近更新 更多