0
votes

New to dotnet

VS2017 version: 15.8

.Net core SDK: 2.1.403

My project is showing following Exception:

C:\gitprojects\crm-api\DA Digital APIs\DA.Digital.CRM.Api\DA.Digital.CRM.Api.csproj : warning NU1701: Package 'Microsoft.AspNet.Cors 5.2.6' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. C:\gitprojects\crm-api\DA Digital APIs\DA.Digital.CRM.Api\DA.Digital.CRM.Api.csproj : warning NU1701: Package 'Microsoft.AspNet.WebApi.Core 5.2.6' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. C:\gitprojects\crm-api\DA Digital APIs\DA.Digital.CRM.Api\DA.Digital.CRM.Api.csproj : warning NU1701: Package 'Microsoft.AspNet.Cors 5.2.6' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. C:\gitprojects\crm-api\DA Digital APIs\DA.Digital.CRM.Api\DA.Digital.CRM.Api.csproj : warning NU1701: Package 'Microsoft.AspNet.WebApi.Core 5.2.6' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.

Q: What could be the reason? Is there any solution?

1
This package may not be fully compatible with your projectJazb
means it is probably not compatible with your target of .net core 2.1.0Jazb
.NET Core 2.0+ implements .NET Standard 2.0, which has broad API footprint covering most of .NET Framework, aside from some Windows-specific APIs. Because of this, the compiler will allow you to reference full framework libraries from a .NET Core project, even though they're not technically compliant. You get this warning though, to inform you that the library might not actually work. It is on you to verify the functionality, and then the warning can be suppressed. However, in this specific case, you are in fact using the wrong libraries in the first place, so you should actually fix that.Chris Pratt

1 Answers

3
votes

You're using the full framework nuget packages. Use the AspNetCore packages instead.

Let's look at the first warning:

C:\gitprojects\crm-api\DA Digital APIs\DA.Digital.CRM.Api\DA.Digital.CRM.Api.csproj : warning NU1701: Package 'Microsoft.AspNet.Cors 5.2.6' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.

It's complaining about Microsoft.AspNet.Cors - nuget link.
Use Microsoft.AspNetCore.Cors instead - nuget link.

In general you want to use packages that's fully compatible with what you're targeting. In this case, netstandard2.0 or netcoreapp2.1. (You may check dependencies in nuget.org to verify that.)


For a quickfix, have you tried using Microsoft.AspNetCore.App? nuget link
If not I'd recommend adding that and getting rid of the ASP.NET packages it's complaining about. That'll fix your problem.