2011-07-26 49 views
0

我有一個需要一些外部依賴項的單元測試項目。這些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位的,我想這些組件的路徑是........ \外部\ EA ** ** I386 \ Core.dll。換句話說,我如何告訴msbuild選擇正確的構建目標。

感謝

+0

看看這裏:http://stackoverflow.com/questions/1997268/how-to-reference-different-version-of-dll-with-msbuild – Mrchief

回答

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> 

你必須精確地discovere這對於$值(平臺)的項目正在使用,這將對項目的XML進行簡單的檢查。