简体   繁体   中英

Migrating from .Net Core 3.1 to .NET 5

I am attempting to upgrade an ASP.NET Core 3.1 project to .NET 5.0. I am getting warning messages like this:

Warning NU1701 Package 'Microsoft.AspNet.WebApi.Core 5.2.7' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework 'net5.0'. This package may not be fully compatible with your project.

I have ensured that the Microsoft.AspNet.WebApi packages are most recent but it doesn't seem to have helped at all. **Edit:** and have since removed it; however I am still seeing warnings about this package. This is the current list of dependencies for the project: 依赖项

This version of the .NET is required for Entity Framework Core to work properly and I would like the whole project to be upgraded

How do I resolve this problem?

Microsoft.AspNet.WebApi.* packages are for the very old ASP.NET Web API framework. You have:

  • A direct dependency, through the reference to Microsoft.AspNet.WebApi.Core , and
  • An indirect dependency, through Swashbuckle

The first one can be removed, since Swashbuckle will reference it transitively anyway.

The second one is... weird. You have dependencies to both Swashbuckle (an ASP.NET Web API package) and Swashbuckle.AspNetCore (an ASP.NET Core package). Given that there's no way you could be using ASP.NET Web API stuff in ASP.NET Core 3.x, my impression is that you should be able to safely remove it without any compiler error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM