Reputation: 892
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?
Upvotes: 0
Views: 1433
Reputation: 14034
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.
Upvotes: 3