Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
677 views
in Technique[技术] by (71.8m points)

migration - Reference ASP .NET Core 5 assemblies from class library

I'm a little bit lost and confused when migrating from .NET Core 2.2. to .NET 5. I've developed as class library which was referencing let's say Microsoft.AspNetCore.Http.Abstractions.

When I create new NET 5 application it implicitly references version 5.0.0 of said assembly (I understand because it uses Microsoft.NET.Sdk.Web, but when class library is created the highest version available from Nuget is 2.2.0.

How can I reference 5.0.0 from class library? Should I reference 2.2.0 (it still downloads it though) and hope that 5.0.0 is backwards compatible? What was the intended usage pattern?

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="???"/>
  </ItemGroup>
</Project>

Edit: I found out that is should be done with:

<FrameworkReference Include="Microsoft.AspNetCore.App"/>

bit this will only work if targetting net5, is it possible to reference said assembly from netstandard2.1? If netstandard2.1 can only reference version 2.2.0 is it safe to do it?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...