[英]How to remove default/locked assembly reference from .NET SDK csproj that is targeting full .NET Framework?
I have a new csproj format project that is using <TargetFramework.net472</TargetFramework>
(targeting full .NET Framework), which adds default set of immutable assembly references to the project (as shown on the screenshot).我有一个新的 csproj 格式项目,它正在使用
<TargetFramework.net472</TargetFramework>
(针对完整的 .NET 框架),它向项目添加了一组默认的不可变程序集引用(如屏幕截图所示)。
For example, System.Drawing
is locked and can not be removed.例如,
System.Drawing
已锁定且无法删除。
Yes, I know, if I don't use any classes from System.Drawing
, it will not be actually referenced.是的,我知道,如果我不使用
System.Drawing
中的任何类,它就不会被实际引用。
But still, is there any way to remove/ignore/hide it?但是,有什么办法可以删除/忽略/隐藏它吗?
I've already tried alias
trick to hide it:我已经尝试过
alias
技巧来隐藏它:
<Reference Update="System.Drawing">
<Aliases>excluded</Aliases>
<Private>false</Private>
</Reference>
Did not work.不工作。
I have nothing against System.Drawing
per se — but, what if I have another assembly which exports types with exact same namespaces and names — how to "shadow" existing reference?我并不反对
System.Drawing
本身——但是,如果我有另一个程序集导出具有完全相同的命名空间和名称的类型——如何“隐藏”现有引用呢?
Update: csproj looks like this:更新:csproj 看起来像这样:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
</Project>
Just in case anybody is still searching for an answer: set the DisableImplicitFrameworkReferences property to true, then add references to the assemblies that are actually needed.以防万一有人仍在寻找答案:将DisableImplicitFrameworkReferences属性设置为 true,然后添加对实际需要的程序集的引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.