2
votes

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: Dependencies

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?

1
The error complains that you use an ASP.NET package, not ASP.NET Core. Have you added the wrong package to the ASP.NET Core application by mistake? ASP.NET Core packages contain AspNetcore in their name. What you used is the Core package of AspNet.WebApiPanagiotis Kanavos
@CamiloTerevinto I am attempting to update an outdated project to .NET 5...it is a Web API (Web Service) project. The original (outdated) version of the project used an even older version of the Microsoft.AspNet.WebApi package and I have updated it to current. The warnings persist. If I do not need this package for my service, then I'll look to remove it. Do you know if it's required for a service project?Frinavale
@CamiloTerevinto thank you, I have removed it and the project seems to be fine without it BUT I am still seeing the error message about Package 'Microsoft.AspNet.WebApi.Client 4.0.20710' being restored using a framework version I'm not targeting. Do you know WHY I'm seeing this after I removed the package (and restarted visual studio)Frinavale
@CamiloTerevinto I have updated my original post to include a picture of my dependencies. I don't see the package...?Frinavale
Got it: get rid of Swashbuckle and use Swagger/SwaggerUI...oh the fun of upgrading! Thank you!!Frinavale

1 Answers

4
votes

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.