Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"dotnet restore" doesn't restore all required dependent lib versions #6309

Closed
livarcocc opened this issue Dec 13, 2017 · 7 comments
Closed
Labels
Functionality:Restore Resolution:Question This issues appears to be a question, not a product defect
Milestone

Comments

@livarcocc
Copy link

From @davethieben on December 13, 2017 14:11

My project is referencing a newer version of Newtownsoft.Json, and an old library that references an older Newtonsoft.Json package. in the 2.0 SDK, when I "dotnet restore", I am only getting the old version. I did not have this problem with the 1.0 SDK.

Steps to reproduce

  1. Create a new Console App (ConsoleApp1).
  2. Add a Nuget package to ConsoleApp1 of a recent version (i.e., Newtonsoft.Json v9.0.1)
  3. Add a Class Library to the solution (ClassLibrary1).
  4. Add same Nuget package to ClassLibrary1 of an older version (i.e., Newtonsoft.Json v6.0.4).
  5. Reference ClassLibrary1 from ConsoleApp1.
  6. Restore and build. it should work fine in VS, and "dotnet run" works fine.
  7. Run: dotnet restore --packages .\pkgs

Expected behavior

In the "pkgs" dir, I should see "newtonsoft.json" with both "6.0.4" and "9.0.1" dirs.

Actual behavior

I am only getting the "6.0.4" dir.

Additional steps

  1. Add a global.json to the solution folder and set "sdk" to 1.0.4 repeat the above steps, and note that both version folders are now present.

Environment data

Output from when I performed these steps:

C:\Development\ConsoleApp1>dotnet --info
.NET Command Line Tools (2.1.2)

Product Information:
 Version:            2.1.2
 Commit SHA-1 hash:  5695315371

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10240
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.2\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.3
  Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df


C:\Development\ConsoleApp1>dotnet restore --packages .\pkgs-2.1.2
  Restoring packages for C:\Development\ConsoleApp1\ClassLibrary1\ClassLibrary1.csproj...
  Restoring packages for C:\Development\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj...
  Installing Newtonsoft.Json 6.0.4.
  Installing System.ComponentModel 4.0.1.
  Installing Microsoft.Extensions.Logging.Abstractions 1.0.0.
  Installing Microsoft.Extensions.DependencyInjection.Abstractions 1.0.0.
  Installing Microsoft.Extensions.Logging 1.0.0.
  Generating MSBuild file C:\Development\ConsoleApp1\ClassLibrary1\obj\ClassLibrary1.csproj.nuget.g.props.
  Generating MSBuild file C:\Development\ConsoleApp1\ConsoleApp1\obj\ConsoleApp1.csproj.nuget.g.props.
  Restore completed in 218.93 ms for C:\Development\ConsoleApp1\ClassLibrary1\ClassLibrary1.csproj.
  Restore completed in 230.38 ms for C:\Development\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj.

And after adding the global.json

C:\Development\ConsoleApp1>dotnet --info
.NET Command Line Tools (1.0.4)

Product Information:
 Version:            1.0.4
 Commit SHA-1 hash:  af1e6684fd

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10240
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.4

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.3
  Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

C:\Development\ConsoleApp1>dotnet restore --packages .\pkgs-1.0.4
  Restoring packages for C:\Development\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj...
  Restoring packages for C:\Development\ConsoleApp1\ClassLibrary1\ClassLibrary1.csproj...
  Installing Newtonsoft.Json 6.0.4.
  Installing System.Runtime.InteropServices 4.1.0.
  Installing System.Runtime.Extensions 4.1.0.
  Installing System.Collections.Concurrent 4.0.12.
  Installing System.Collections 4.0.11.
  Installing System.Resources.ResourceManager 4.0.1.
  Installing System.Reflection 4.1.0.
  Installing System.Linq.Expressions 4.1.0.
  Installing System.Linq 4.1.0.
  Installing System.Globalization 4.0.11.
  Installing System.Diagnostics.Debug 4.0.11.
  Installing System.ComponentModel 4.0.1.
  Installing Microsoft.Extensions.Logging.Abstractions 1.0.0.
  Installing Microsoft.Extensions.DependencyInjection.Abstractions 1.0.0.
  Installing System.Threading 4.0.11.
  Installing Newtonsoft.Json 9.0.1.
  Installing Microsoft.Extensions.Logging 1.0.0.
  Generating MSBuild file C:\Development\ConsoleApp1\ClassLibrary1\obj\ClassLibrary1.csproj.nuget.g.props.
  Writing lock file to disk. Path: C:\Development\ConsoleApp1\ClassLibrary1\obj\project.assets.json
  Restore completed in 330.04 ms for C:\Development\ConsoleApp1\ClassLibrary1\ClassLibrary1.csproj.
  Generating MSBuild file C:\Development\ConsoleApp1\ConsoleApp1\obj\ConsoleApp1.csproj.nuget.g.props.
  Writing lock file to disk. Path: C:\Development\ConsoleApp1\ConsoleApp1\obj\project.assets.json
  Restore completed in 762.2 ms for C:\Development\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj.

  NuGet Config files used:
      C:\Users\dave\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

  Feeds used:
      \\buildserver\SharedComponents\Nuget
      https://api.nuget.org/v3/index.json
      C:\Users\dave\.nuget\packages
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

  Installed:
      1 package(s) to C:\Development\ConsoleApp1\ClassLibrary1\ClassLibrary1.csproj
      16 package(s) to C:\Development\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj

Am I missing something? thanks.

Copied from original issue: dotnet/cli#8233

@livarcocc
Copy link
Author

This is by design.

In the 2.0 SDK, we started using the NuGetFallback folder as a way to improve performance and avoid hitting the network too much.

This fallback folder contains a set of packages, including newtonsoft.json 9.0.1 and when NuGet runs a dotnet restore, if it finds the package in the fallback folder, it uses it and does not copy the package to the user's cache. Which is what you are seeing above.

Given that the system is behaving exactly as we expect it to, I am going to close this issue. If you still have any questions or comments, please just re-activate or comment.

@livarcocc
Copy link
Author

From @davethieben on December 13, 2017 18:22

that makes sense. however, then I would argue that the "--packages" cli option isn't working correctly. I am assuming that the point of that option (and what we have been using it for) is to restore ALL packages to the output location specified, which it does not, even given a "--force" option.

@livarcocc
Copy link
Author

I will move this issue to NuGet as it will be easier to get an accurate explanation for their reasoning there.

@emgarten
Copy link
Member

@davethieben would you explain more about your scenario? Why do you need the packages in a certain location, are you using these outside of the normal project restore/build?

The workaround for this is to disable the fallback folders so that only the packages folder is used.

@davethieben
Copy link

davethieben commented Dec 14, 2017

we are distributing our app via an internal NuGet server, and need to publish all dependent packages to the server as well. if there is a better way to do that, lmk.

re: workaround; how to disable the fallback folder?

thanks.

@emgarten
Copy link
Member

DisableImplicitNuGetFallbackFolder=true in your project or pass /p:DisableImplicitNuGetFallbackFolder=true when restoring

@emgarten emgarten added this to the 4.6 milestone Dec 15, 2017
@emgarten emgarten added Resolution:Question This issues appears to be a question, not a product defect Functionality:Restore labels Dec 15, 2017
@LightVolk
Copy link

@livarcocc , can i disable fallback repository? Because, ms build find old version (for example, ver 5.2.0) of package from this folder. But at my local repo i use new version (5.2.1). And i want that all my services uses this version of package.

But the problem is, that nobody use this problem package directly. All of services uses this from another packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Restore Resolution:Question This issues appears to be a question, not a product defect
Projects
None yet
Development

No branches or pull requests

4 participants