根据构建目标更改引用路径

时间:2011-07-26 18:59:11

标签: msbuild

我有一个单元测试项目,需要一些外部依赖项。这些dependendies有两种口味: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选择正确的构建目标。

由于

1 个答案:

答案 0 :(得分:0)

只需在引用上添加一个条件,或者如下所示,在包含它们的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>

您必须确切地了解项目正在使用的$(平台)的哪些值,这将简单地检查项目的XML。