.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 位程序集引用但是链接的(
..)始终 使用 32 位(因此该应用程序已损坏)。
项目文件中不再有任何 CPU,我“期望”它也能很好地处理包含的内容……但事实并非如此。我有什么遗漏的吗?
Since we have three assemblies that come in explicit x86 and x64 versions, I've edited the corresponding .csproj file(s) to use, for example, a block like this:
<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>
When reloading the .csproj file in Visual Studio 2010 and using 'x86' as platform, all works perfectly fine. When choosing 'x64' as platform, the proper 64bit assembly reference is used BUT the linked ( <Content Include= ...>
..) always uses the 32bit ones (and therefore the app is broken).
There's no Any CPU anymore in the project files and I would have 'expected' it to work just fine for the content includes, too.. but it doesn't. Is there anything I am missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们将 Condition 属性放在 Reference 元素上,效果很好。也许 Condition 属性还需要添加到 Content 元素中? (您真的需要 Reference 元素和 Content 元素吗?)例如:
We put the Condition attribute on the Reference element and that works fine. Perhaps the Condition attribute also needs to be added to the Content element? (Do you really need both the Reference element and the Content element?) For example:
所以这“只是”一个视觉/显示问题。下面的构建确实使用了正确的引用等,只有 VS2010 显示错误的引用。一切都很好,只是看不见。
So this is 'only' a visual / display problem. Underneath builds do use the proper references etc, only VS2010 displays the wrong one. All good, just not visible.
那么这个问题有答案了吗?如果没有,我建议切换 ItemGroup 的顺序并查看是否获得相反的结果(它在 x64 中工作,但在 x86 上 Visual Studio 显示错误的引用)。
So has this question been answered? If not, I would recommend switching the order of the ItemGroups and seeing if the opposite result is achieved (that it works in x64 but on x86 Visual Studio displays the wrong reference).