Previously in ASP.NET Core 2.0 when you create a new web project with dotnet new web
and you open .csproj
file you would have PackageReference
entry like this:
But today I started playing with ASP.NET Core 3.1, and I noticed that when you create a new project in the same manner, the .csproj file contains only this:
Where did the PackageReference
entry go and how does ASP.NET Core knows how to build and run the project without this information?
The distribution mechanism of shared framework reference assemblies and build logic changed. It is no longer based on NuGet and uses FrameworkReference
items.
The Web SDK (Microsoft.NET.Sdk.Web
) references this framework automatically.
If you need to use types / APIs only available in ASP.NET Core and not via separate NuGet packages from non-Web projects (Sdk="Microsoft.NET.Sdk"
), you can use:
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>