Drew Noakes
Drew Noakes

Reputation: 310907

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?

Upvotes: 8

Views: 1795

Answers (4)

Hinrich
Hinrich

Reputation: 13983

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.

Upvotes: 1

NickBeaugié
NickBeaugié

Reputation: 740

I had this problem when a common library project was in more than one solution.

The directory location of the library project was changed and the global.json file was updated in one solution.

In the other, the sln file was updated for the new file location of the project. However, the global.json not. As the project had been moved to a higher directory, the old global.json file was referencing too specific a location.

Upvotes: 0

MeanGreen
MeanGreen

Reputation: 3305

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.

Upvotes: 1

Drew Noakes
Drew Noakes

Reputation: 310907

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.

Upvotes: 6

Related Questions