I am working on internal libraries for my organization. I need to reference certain types that normally "belong" to web apps, eg. to provide some extensions:
WebApplicationOptions
HttpContext
If I use <Project Sdk="Microsoft.NET.Sdk">
, i don't have references to these types and can't find any nuget package which contains them. If i use <Project Sdk="Microsoft.NET.Sdk.Web">
, i can't build my class library because it is treated as application and has to specify entry point.
So, my question in general: what is the right way to write libraries for ASP.NET Core 6?
Back in core 2.x days there were packages for everything, like Microsoft.AspNetCore.Http.Abstractions
. They are all stuck at version 2.2.0
and i assume they're not usable now?
CodePudding user response:
You need to add a FrameworkReference
instead of a PackageReference
as described here.
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>