如何为System.Core创建外部别名? [英] How to create an extern alias for System.Core?

查看:60
本文介绍了如何为System.Core创建外部别名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我绝对需要System.Core的外部别名.不幸的是,在.Net 4.0项目中,您甚至无法添加对System.Core的引用,因为显然,构建系统默认情况下会包括它.有人对我如何强制系统让我为此lib指定一个extern别名有任何想法吗?谢谢!

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!

推荐答案

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

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.

您可以通过编辑csproj msbuild文件并添加以下内容来覆盖它:

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

<PropertyGroup>
   <AdditionalExplicitAssemblyReferences/>
</PropertyGroup>

最后.

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

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>

到包含引用(或新引用)的ItemGroup.

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

您现在可以使用

引用System.Core类型

You can now refer to a System.Core type using

ActualSystemCore::System....

这篇关于如何为System.Core创建外部别名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆