Showing classes from indirectly referenced packages in .NET Core

后端 未结 2 1166
迷失自我
迷失自我 2020-12-05 14:54

I am trying to implement basic UoW/Repository pattern with ASP.NET/Entity Framework Core and I have encountered very troubling behavior.

My solution consists of 4 pro

相关标签:
2条回答
  • 2020-12-05 15:34

    That is intended behavior. It is called meta-packages and used for example for the NETStandard.Library package to include all libraries of the base class library. I do not think there is a way hiding them.

    0 讨论(0)
  • 2020-12-05 15:42

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

    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>
    

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

    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:

    In B.csproj

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

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

    0 讨论(0)
提交回复
热议问题