20
votes

I am getting the following warning in my .net core 2.2 application.

Warning NU1701 Package 'Microsoft.AspNet.WebApi.Core 5.2.7' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project.

Is there any alternative for this package?

1
No, you added the wrong package. You don't need to add any package to an ASP.NET Core project to create a Web API controller. Check Tutorial: Create a web API with ASP.NET Core MVC. The controller architecture has changed in .NET Core and now supports both Web API and MVC controllers derived from the same class, ControllerBasePanagiotis Kanavos
How did Microsoft.AspNet.WebApi.Core end up in an ASP.NET Core project anyway?Panagiotis Kanavos
I am upgrading a .net 4.5.1 application to .net core 2.2. I was using types like BsonMediaTypeFormatter and BsonReader. I see that Microsoft.AspNet.WebApi.Core has these but unfortunately, that is not supported.Balaji Kanagaraju
It's a different architecture, not a matter of something being supported or not. Web API is baked into ASP.NET Core now. Your real question is different though - how to add BSON support to ASP.NET Core? There are many duplicates that show you need to add the WebAPIContrib.Core packagePanagiotis Kanavos
Don't upgrade an existing project, because you'll miss out on much of the new and awesome stuff in .NET Core (e.g. improved csproj file format), as well as potentially having a lot of cruft left over, as well as running into these kinds of issues. Rather make a new Core project, copy all your code into that, then add the missing references as needed.Ian Kemp

1 Answers

12
votes

As said in comments, this is not needed for a ASP.NET Core project. Remove it via NuGet and you should be good to go.