Dependency specified was X but ended up with Y
Asked Answered
T

4

8

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?

Tippets answered 12/10, 2016 at 13:28 Comment(0)
T
6

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.

Tippets answered 13/10, 2016 at 7:51 Comment(0)
T
1

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.

Tosh answered 23/2, 2017 at 10:15 Comment(0)
A
1

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.

Ardyth answered 7/3, 2018 at 13:19 Comment(0)
W
0

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.

Walleye answered 24/4, 2017 at 13:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.