Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependency specified was X but ended up with Y

I've updated a class library's project.json to target netstandard1.3 and net64.

With that change:

$ dotnet restore
log  : Restoring packages
warn : Dependency specified was NETStandard.Library (>= 1.3.0) but ended up with
       NETStandard.Library 1.6.0.

I'm publishing a library and really need to target netstandard1.3/net46.

How can I diagnose why a higher version is being used instead?

like image 359
Drew Noakes Avatar asked Oct 12 '16 13:10

Drew Noakes


3 Answers

I followed up with this on a NuGet issue and @emgarten pointed out that the NETStandard.Library package only have a 1.6.0 version, but that 1.6.0 version contains assemblies for netstandard1.3.

So in this case the 1.3 version I requested doesn't exist anywhere, and the warning is a notification that it's using a higher version instead.

The diagnostic could still be more informative however. You can vote on the issue if it also trips you up and you'd like to see it made more clear.

like image 170
Drew Noakes Avatar answered Nov 15 '22 15:11

Drew Noakes


When you're not dealing with NuGet, but like in my case your own projects, this error can also occur.

The first thing you want to do is make sure you have the correct version referred in the Solution Items -> global.json.

Then you might need to refresh each project.json referring this project, since VS2015 does not always refresh properly:

  1. Open the project.json and cut the line giving the warning
  2. Save the file and wait for the 'Restoring Packages... message' to disappear
  3. Paste the line back in
  4. Save the file again

Another way to force a refresh is by running dotnet restore --no-cache at the solution or project level.

like image 34
MeanGreen Avatar answered Nov 15 '22 15:11

MeanGreen


For me, just deleting the lock file (project.lock.json) worked. After deleting this file, Nuget restored all the packages automatically and the problem disappeared.

Disclaimer

Although it worked for me, I am not sure if this is a profound way of doing things that will work for everyone. So please be aware of what you are doing before deleting this file.

like image 38
Hinrich Avatar answered Nov 15 '22 17:11

Hinrich