且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

显示 .NET Core 中间接引用的包中的类

更新时间:2021-09-17 22:13:48

我已经为此苦苦挣扎了几个月,终于找到了一种方法来禁用 Core 中项目的传递引用.

I've been struggling with this for months and finally found a way to disable the transitive references of projects in Core.

在 .Facade.EF 的 .csproj 文件中,您可以将 PrivateAssets="All" 添加到 .DAL 的 ProjectReference:

In the .csproj file for .Facade.EF, you can add PrivateAssets="All" to the ProjectReference to .DAL:

<ItemGroup>
  <ProjectReference Include="...DAL.DAL.csproj" PrivateAssets="All" />
</ItemGroup>

使用此设置,引用 .Facade.EF 的项目也不再引用 .DAL.

With this setting, projects that reference .Facade.EF no longer reference .DAL too.

用更抽象的术语来说,如果您希望 A 引用 B,B 引用 C,但不想 A 引用 C,请添加:

In more abstract terms, if you want A to reference B and B to reference C, but don't want A to reference C, add this:

在 B.csproj 中

<ItemGroup>
  <ProjectReference Include="..CC.csproj" PrivateAssets="All" />
</ItemGroup>

来源:https://github.com/dotnet/project-system/issues/2313