Lost
Lost

Reputation: 13655

was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '

I am trying to reference a nuget package which is clearly .NetStandard2.0. We own the source code for this package and written it to target .netstandard. We do have a CI pipeline so that when we push this code, it builds and releases the nuget package. When I try to reference the resulting nuget package into my current .netCore application, i get following error:

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.

That does not make any sense to me. So far I have tried following debugging steps:

Not sure what makes it think that it was targeting at any point. below is how my .csproj configuration looks like

<TargetFramework>netstandard2.0</TargetFramework>

Not sure if any other config block matters here but let me know if you need more info on this. Any ideas?

Upvotes: 36

Views: 52981

Answers (5)

Crazy Cat
Crazy Cat

Reputation: 1462

I had the same error. For me I had to remove the NuGet package:

Oracle.ManagedDataAccess

And instead install:

Oracle.ManagedDataAccess.Core

Upvotes: 0

Nigel Findlater
Nigel Findlater

Reputation: 1724

I had the same problem. To fix this

  1. Look in VS2019 under dependencies / Packages.
  2. Then look for the packages with the warning sign next to them.
  3. Goto your windows profile directory and delete the corresponding folder under .nuget
  4. Delete the reference under dependencies / Packages
  5. Add the Nuget package via Manage Nuget Packages for solution

Upvotes: 3

Chronogeran
Chronogeran

Reputation: 81

I ran into this issue as well. In my case, when the DLL was packaged and placed in the lib/ folder, the import warning occurred. It was solved by placing the packaged DLL in the lib/netstandard2.0 folder.

Upvotes: 8

TomP
TomP

Reputation: 109

I ran in to a similar issue where I was publishing my own NetStandard2.0 package via Azure Artifacts and then attempting to consume it in a netcore application.

It turned out that the problem was that I had named my package the same as an existing NuGet package. My Azure Artifacts nuget feed was configured correctly in Visual Studio, but when it attempts to install the package it tries the default NuGet feed first and picks up the other one (which happened to be NetFramework only) rather than mine.

Once I renamed my package to be unique (I just added my own namespace) and re-published it all worked properly.

I guess that might not be the issue for everyone but it was for me.

Upvotes: 5

cdev
cdev

Reputation: 5401

You have to use every packages in your project compatible with .NETCoreApp,Version=v2.0.

There should be some package name before "was" in your error message. For ex:

Package 'Microsoft.AspNet.WebApi.Client 5.2.2' was restored
Package 'EntityFramework 6.2.0' was restored 

Upvotes: 3

Related Questions