58

When I add a NuGet package (latest version of NuGet and Visual Studio 2015) it hangs at "Attempting to gather dependencies" for ~5 minutes before installing the package. I can point to NuGet.org, our internal server, or a folder on my local machine. All behave exactly the same.

Feasoron
  • 3,471
  • 3
  • 23
  • 34
  • For me it just took a while. Go ahead and try the `-Verbosity detailed` flag to see where the command hangs – feupeu May 01 '18 at 09:42

6 Answers6

81

After a lot of digging (I had this issue for a long time before posting) I found the issue. One of the NuGet package sources in my list was down. If I remove that from the list, everything goes smoothly. With it in, it bogs down even if no packages in my packages.config are related to that source.

Feasoron
  • 3,471
  • 3
  • 23
  • 34
  • 7
    Semi-related: Happens on bad connections as well. I left it for a few minutes, and it eventually went through. Might be useful to future readers if they only have the official nuget repo – Rob Apr 12 '16 at 11:21
  • In my case, the other package source was not really down, as it was responding. However turning off all sources besides nuget.org, fixed the problem for me. – Paweł Forys Feb 14 '17 at 11:07
  • 1
    We're running an internal NuGet server for a customer, which is behind a VPN. I'd forgotten to turn on the VPN. As soon as I did, the package downloaded just fine (even though it was from the official NuGet servers and had nothing to do with our internal server). – HenricF Apr 10 '17 at 06:19
43

I struggled with the same issue for too long and almost all the advice I read was to update nuget VS extension (I'm using VS package manager console) or restart VS and nothing worked...

My setup (at time of issue):

  • VS 2015 Pro Update 2
  • Package Manager Console Host Version 3.4.3.855

Solution that finally worked for me:

  1. Close VS if open.
  2. Delete %AppData%\NuGet\NuGet.Config
  3. Open VS and package manager console (this will recreate Nuget.config)

This updated my nuget.org feed to no longer point to www.nuget.org/api/v2 (see image below)

New nuget.org feed

  1. My Microsoft and .NET feed was also selected and I had to deselect that too: enter image description here

After this installing packages no longer hung on 'Attempting to gather dependency information for package...'

Kudos to https://stackoverflow.com/a/36461793/4977243 for the idea of deleting nuget.config.

Community
  • 1
  • 1
Quinton Smith
  • 2,550
  • 18
  • 17
2

This morning, all of our builds started failing. After doing some digging, we figured out that it was hanging on https://www.nuget.org/api/v2 while resolving dependencies. More digging, it was connecting and downloading but seemed to be caught in a loop. Each time we cancelled the build, it left a Nuget.exe running in the background - CPU got hot.

Turns out that nuget.org upgraded their servers last night (1/13/2016) and the version of Nuget.exe that our builds were running (2.7.2) was choking.

The fix (at least for us) was to upgrade to 2.8.6 (https://dist.nuget.org/win-x86-commandline/v2.8.6/nuget.exe). I know that isn't the most current version but it worked for us. We'll upgrade later after the smoke dissipates!

neoscribe
  • 2,203
  • 1
  • 21
  • 18
0
  1. Please go to the location of Nuget.config in Windows machine (of user) %appdata%\NuGet.
  2. Here you can remove the key(s) of the incorrect package's location(s)/link(s).
  3. Now try the same command in SHELL to download package.
Suriya
  • 848
  • 10
  • 15
0

For me, it has always been a wrongly configured proxy issue. When the error says: "Gathering dependencies....", its usually trying to download some package.

If all the nuget configurations are right, please do check the system proxy.

0

My issue is the Nuget Packages folder doesn't exist. I have renamed my local folder name from "packages" to "NugetPackages". Checking the contents of the csproj file is worth a try.

suphero
  • 497
  • 2
  • 8
  • 18