如何为 System.Core 创建外部别名?

发布于 2024-08-29 03:43:01 字数 119 浏览 3 评论 0原文

我的项目中绝对需要 System.Core 的外部别名。不幸的是,在 .Net 4.0 项目中,您甚至无法添加对 System.Core 的引用,因为显然构建系统默认包含它。有谁知道如何强制系统让我为该库指定外部别名?谢谢!

I absolutely need an extern alias for System.Core in my project. Unfortunately, in a .Net 4.0 project, you cannot even add a reference to System.Core because, apparently, the build system includes it by default. Does anyone have any idea on how I can coerce the system to let me specify an extern alias for this lib? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十秒萌定你 2024-09-05 03:43:01

这个问题很老了,但我遇到了同样的问题。据我了解,这是由于 Visual Studio 隐式添加了对 System.Core 的引用。

您可以通过编辑 csproj msbuild 文件并

<PropertyGroup>
   <AdditionalExplicitAssemblyReferences/>
</PropertyGroup>

在末尾添加: 来覆盖此设置。

这将禁用我认为 Visual Studio 已使用 /p[roperty] 开关传递给 MSBuild 的任何 AdditionalExplicitAssemblyReferences
当然,我们现在仍然需要添加 System.Core 引用,因为它不再被引用。 实现此目的

<Reference Include="System.Core">
   <RequiredTargetFramework>3.5</RequiredTargetFramework>
   <Aliases>global,ActualSystemCore</Aliases>
</Reference>

通过添加到包含引用(或新引用)的 ItemGroup

。您现在可以使用 System.Core 类型来引用

ActualSystemCore::System....

This question is old but I ran into the same problem. As far as I understood, this is due to Visual Studio implicitly adding a reference to System.Core.

You can override this by editing your csproj msbuild file and adding:

<PropertyGroup>
   <AdditionalExplicitAssemblyReferences/>
</PropertyGroup>

at the end.

This disables any AdditionalExplicitAssemblyReferences that I assume Visual Studio has passed to MSBuild using the /p[roperty] switch.
Of course, we now still have to add the System.Core reference as it is no longer referenced. Do so by adding

<Reference Include="System.Core">
   <RequiredTargetFramework>3.5</RequiredTargetFramework>
   <Aliases>global,ActualSystemCore</Aliases>
</Reference>

to the ItemGroup that contains references (or a new one).

You can now refer to a System.Core type using

ActualSystemCore::System....
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文