Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
683 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...