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:
dotpeek
to make sure that it in fact is a .netstandard package and it is. 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?
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.
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.
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
I had the same problem. To fix this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With