.net – .csproj的平台特定ItemGroup可用于汇编引用,但不包含内容?

由于我们有三个程序集是明确的x86和x64版本,所以我已经编辑了相应的.csproj文件,例如使用如下的块:

  <ItemGroup Condition=" '$(Platform)' == 'x86' ">
    <Reference Include="CaliberRMSDK">
      <HintPath>..\Libraries\CaliberRMSDK_IKVM\32bit\CaliberRMSDK.dll</HintPath>
    </Reference>
    <Content Include="..\Libraries\CaliberRMSDK_IKVM\32bit\ikvm-native.dll">
      <Link>ikvm-native.dll</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="..\Libraries\CaliberRMSDK_IKVM\32bit\JVM.dll">
      <Link>JVM.dll</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <ItemGroup Condition=" '$(Platform)' == 'x64' ">
    <Reference Include="CaliberRMSDK">
      <HintPath>..\Libraries\CaliberRMSDK_IKVM\64bit\CaliberRMSDK.dll</HintPath>
    </Reference>
    <Content Include="..\Libraries\CaliberRMSDK_IKVM\64bit\ikvm-native.dll">
      <Link>ikvm-native.dll</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="..\Libraries\CaliberRMSDK_IKVM\64bit\JVM.dll">
      <Link>JVM.dll</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

当在Visual Studio 2010中重新加载.csproj文件并使用’x86’作为平台时,所有这些都可以很好的工作。当选择“x64”作为平台时,使用正确的64位程序集引用,但链接的(< Content Include = ...> ..)总是使用32位的(因此应用程序被破坏)。

在项目文件中不再有任何CPU,我会“预期”它的内容也适用,但是它并没有。有什么我失踪的吗?

我们把Condition属性放在Reference元素上,并且工作正常。也许Condition属性也需要添加到Content元素? (你真的需要Reference元素和Content元素吗?)例如:

<Reference Include="SomeLib" Condition="$(Platform)=='x86'">
  <HintPath>..\..\ThirdParty\SomeLib\clr4\x86\SomeLib.dll</HintPath>
  <Private>False</Private>
</Reference>
<Reference Include="SomeLib" Condition="$(Platform)=='x64' Or $(Platform)=='AnyCPU'">
  <HintPath>..\..\ThirdParty\SomeLib\clr4\x64\SomeLib.dll</HintPath>
</Reference>
http://stackoverflow.com/questions/4470308/csprojs-platform-specific-itemgroup-works-for-assembly-references-but-not-cont

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:.net – .csproj的平台特定ItemGroup可用于汇编引用,但不包含内容?