0
votes

For some reason I can't install NuGet packages in my solution, package manager just hangs. If I delete the packages folder current NuGet packages can however be restored but new ones can't be added. Package manager hangs when getting dependencies.

Current package source: https://api.nuget.org/v3/index.json

Visual Studio information:

Microsoft Visual Studio Professional 2015 
Version 14.0.25123.00 Update 2 
Microsoft .NET Framework Version 4.6.01055 
Installed Version: Professional 
NuGet Package Manager 3.4.3

Error code:

The HTTP request to 'GET https://api.nuget.org/packages/hangfire.core.1.5.6.nupkg'; has timed out after 100000ms.

What I have tried so far:

  • Closed and reopened Visual Studio
  • Restarted my computer
  • Downloaded all updates from Visual Studio Extensions and Updates
  • Deleted packages folder both in projects folder and under C:\Users\CurrentUser\.nuget. Packages can then be restored upon build but I can't add a new package
  • Visual Studio is being run as administrator
  • Deleted the solutions .suo file
1

1 Answers

0
votes

I don't have a C:\Users\CurrentUser.nuget file so can't comment on that. In my case I've been playing around with my nuget.config file recently due to "dotnet restore" issues with a project built with VS 2015 Update 2 dotnetcore project. To start, nuget.config is located here for me: C:\Users\<username>\AppData\Roaming\NuGet\NuGet.Config

When I change this file it affects my VS 2015 builds (i.e. restore)

For the purposes of this post I will be using the command line to do "dotnet restore"s using ConEmu.

I was having issues with a couple of the package sources in nuget.config requiring proxy authentication. Here is a sample ran from the command line:

$ dotnet restore
log  : Restoring packages for C:\<projectPath>\project.json...
info :   GET https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json 250ms
error: Unable to load the service index for source https://dotnet.myget.org/F/dotnet-cli/api/v3/index.json.
error:   Response status code does not indicate success: 407 (Proxy Authentication Required).

So I reverted back to an earlier version of NuGet.Config which is as follows:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <activePackageSource>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </activePackageSource>
  <packageSources>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </packageSources>
</configuration>

Now when I run "dotnet restore" from the command line I see this:

$ dotnet restore
log  : Restoring packages for C:\<projectPath>\project.json...
info :   GET https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.DotNetHostResolver'
info :   OK https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.DotNetHostResolver' 807ms
info :   GET https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.DotNetHost'
info :   OK https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.DotNetHost' 136ms
log  : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in C:\<projectPath>\project.json...
info : Committing restore...
log  : Writing lock file to disk. Path: C:\<projectPath>\project.lock.json
log  : C:\<projectPath>\project.json
log  : Restore completed in 9030ms.

NuGet Config files used:
    C:\Users\<user>\AppData\Roaming\NuGet\NuGet.Config
    C:\ProgramData\nuget\Config\Microsoft.VisualStudio.Offline.config

Feeds used:
    https://www.nuget.org/api/v2/
    C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

So one suggestion is to try "dotnet restore" via the command line and see what NuGet Config files are being used and which feeds are being used. Additionally you might try adding https://www.nuget.org/api/v2/ as a package source to that NuGet.Config and see if that resolves the issue.

For grins and giggles I added "Hangfire.Core", of which I know nothing about, to my project.json to see how it would react:

"Hangfire.Core": "1.5.6"

It looks like the v2 package source found it but unfortunately my project is not compatible with it so...

$ dotnet restore
log  : Restoring packages for C:\<projectPath>\project.json...
info :   CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.DotNetHostResolver'
info :   CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NETCore.DotNetHost'
log  : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in C:\<projectPath>\project.json...
error: Package Hangfire.Core 1.5.6 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Hangfire.Core 1.5.6 supports: net45 (.NETFramework,Version=v4.5)
error: Package Owin 1.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Owin 1.0.0 supports: net40 (.NETFramework,Version=v4.0)
error: One or more packages are incompatible with .NETCoreApp,Version=v1.0.
info : Committing restore...
log  : Lock file has not changed. Skipping lock file write. Path: C:\<projectPath>\project.lock.json
log  : C:\<projectPath>\project.json
log  : Restore failed in 1219ms.

Errors in C:\<projectPath>\project.json
    Package Hangfire.Core 1.5.6 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Hangfire.Core 1.5.6 supports: net45 (.NETFramework,Version=v4.5)
    Package Owin 1.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Owin 1.0.0 supports: net40 (.NETFramework,Version=v4.0)
    One or more packages are incompatible with .NETCoreApp,Version=v1.0.

NuGet Config files used:
    C:\Users\<user>\AppData\Roaming\NuGet\NuGet.Config
    C:\ProgramData\nuget\Config\Microsoft.VisualStudio.Offline.config

Feeds used:
    https://www.nuget.org/api/v2/
    C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

What's weird is that v2 works at all for me. Granted I have VS 2010, 2012, 2013, and 2015 on my machine. Here is what I found from the nuget homepage:

•NuGet feed v3 (VS 2015 / NuGet v3.x): https://api.nuget.org/v3/index.json
•NuGet feed v2 (VS 2013 and earlier / NuGet 2.x): https://www.nuget.org/api/v2

So once more into the breach..... (i.e. get v3 to work for my "dotnet restore"s in VS 2015)

I changed the project.json to see if "Hangfire.Core" is supported by dotnetcore in it's current beta release:

"Hangfire.Core": "1.6.0-beta3"

I also modified my NuGet.Config as follows to include the v3 version:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <activePackageSource>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </activePackageSource>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </packageSources>
</configuration>

However when I run "dotnet restore" it fails with the above NuGet.Config file:

$ dotnet restore
log  : Restoring packages for C:\<projectPath>\project.json...
error: Unable to load the service index for source https://api.nuget.org/v3/.
error:   An error occurred while sending the request.
error:   A connection with the server could not be established

Ultimately removing the activePackageSources section fixed the error for me and allowed me to pick up v3 finally as a valid package source. Here is the new NuGet.Config that works:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </packageSources>
</configuration>

And here are the command line results, although again "Hangfire.Core" in it's current beta state is not compatible with dotnetcore. But hey, at least the feed is now using v3:

$ dotnet restore
log  : Restoring packages for C:\<projectPath>\project.json...
info :   GET https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json
info :   GET https://api.nuget.org/v3-flatcontainer/hangfire.core/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json 168ms
info :   GET https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethost/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethost/index.json 182ms
info :   OK https://api.nuget.org/v3-flatcontainer/hangfire.core/index.json 578ms
info :   GET https://api.nuget.org/v3-flatcontainer/hangfire.core/1.6.0-beta3/hangfire.core.1.6.0-beta3.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/hangfire.core/1.6.0-beta3/hangfire.core.1.6.0-beta3.nupkg 215ms
log  : Installing Hangfire.Core 1.6.0-beta3.
log  : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in C:\<projectPath>\project.json...
error: Package Hangfire.Core 1.6.0-beta3 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Hangfire.Core 1.6.0-beta3 supports: net45 (.NETFramework,Version=v4.5)
error: Package Owin 1.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Owin 1.0.0 supports: net40 (.NETFramework,Version=v4.0)
error: One or more packages are incompatible with .NETCoreApp,Version=v1.0.
info : Committing restore...
log  : Writing lock file to disk. Path: C:\<projectPath>\project.lock.json
log  : C:\<projectPath>\project.json
log  : Restore failed in 5477ms.

Errors in C:\<projectPath>\project.json
    Package Hangfire.Core 1.6.0-beta3 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Hangfire.Core 1.6.0-beta3 supports: net45 (.NETFramework,Version=v4.5)
    Package Owin 1.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Owin 1.0.0 supports: net40 (.NETFramework,Version=v4.0)
    One or more packages are incompatible with .NETCoreApp,Version=v1.0.

NuGet Config files used:
    C:\Users\<user>\AppData\Roaming\NuGet\NuGet.Config
    C:\ProgramData\nuget\Config\Microsoft.VisualStudio.Offline.config

Feeds used:
    https://api.nuget.org/v3/index.json
    C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

So I came at this from a couple different directions. Perhaps it will help with the issue you're seeing.

Update 1:

So I continued to have issues connecting to the nuget v2 and v3 package sources via "dotnet restore". Most of the time it doesn’t work, sometimes it works. I’m thinking that perhaps my company has multiple proxy servers out there filtering our requests out to the world. I’m thinking our requests out to the world go through one of these servers. Sometimes we’re going through one server for a while when suddenly we are on another server. My guess is that one of these servers lets us through while another doesn’t allow it. I tested it by simply running "dotnet restore" from the command line over and over again. Mostly it failed with this:

$ dotnet restore
log  : Restoring packages for C:\<projectPath>\project.json...
error: Unable to load the service index for source https://api.nuget.org/v3/index.json.
error:   An error occurred while sending the request.
error:   A connection with the server could not be established

However it would successfully work after a while. So that whole rigmarole above is polluted by this firewall/proxy issue we're having.