Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimizing References with .NET Core csproj VS 2017 Tooling

I have .NET Core class libraries I publish to NuGet. After upgrading them to VS 2017 csproj format, they have the following signature.

<Project Sdk="Microsoft.NET.Sdk">
  ...
</Project>

Adding Microsoft.NET.Sdk seems to add references to a base set of libraries. However, as a library author myself, I probably want to only references a minimum set of references. Is that still true and if so, how can it be achieved?

Looking at the ASP.NET Core and Entity Framework Core projects, they seem to use Microsoft.NET.Sdk and do not individually select just the packages they need.

Update

I raised issue dotnet/cli #5994 on GitHub and @davidfowl said:

The new guidance is to reference NETStandard.Library always as a package author.

However, he's not gone into detail as to why?

like image 733
Muhammad Rehan Saeed Avatar asked Oct 17 '22 16:10

Muhammad Rehan Saeed


1 Answers

You can set

<PropertyGroup>
    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>

In your .csproj. This tells the SDK to not reference NETStandard.Library or Microsoft.NETCore.App implicitly.

like image 90
Eric Erhardt Avatar answered Oct 23 '22 06:10

Eric Erhardt