Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2015 NuGet package manager not loading any online packages

I have Visual Studio Enterprise 2015 with Update 3. Recently, NuGet package manager stopped finding any package except the set of offline packages: Microsoft Visual Studio Offline Packages.

I tried opening different projects, restarting visual studio and went to the extent of repairing/upgrading Visual Studio.

I also tried all the methods in this question: VS2015 nuget package manager not finding packages.
Nothing worked.

When I try searching/upgrading packages from Visual Studio NuGet UI, the Loading or Searching progress ring appears, but nothing is loaded. Task Manager and Firewall suggests that no connection is made.

Finally, this appears:

[nuget.org] Unable to load the service index for source http://api.nuget.org/v3/index.json.

An error occurred while sending the request. Unable to connect to the remote server A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

I might be missing something obvious. What am I doing wrong? Any help is appreciated.

like image 418
Wickramaranga Avatar asked Dec 04 '16 05:12

Wickramaranga


People also ask

How do I fix a missing NuGet package?

You can restore packages manually with nuget restore , dotnet restore , msbuild -t:restore , or through Visual Studio. The dotnet build and dotnet run commands automatically restore packages, and you can configure Visual Studio to restore packages automatically when it builds a project.

How do I force a NuGet package to reinstall?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

How do I refresh a NuGet package in Visual Studio?

In Tools -> Options -> NuGet Package Manager -> General you need to select the "Allow NuGet to download missing packages" option which allows NuGet to restore and the "Automatically check for missing packages during build in Visual Studio" which enables on build restore.


1 Answers

Finally, I solved the problem myself. Posting the answer here in case if anyone faces the same issue in the future.

As suggested by the error message, this was a connection issue. Apparently, NuGet uses the environment variable for proxy http_proxy even if the proxy settings are disabled in Windows settings. I removed the environment variable and it fixed the issue.

In fact, the error was documented here: https://github.com/NuGet/Home/issues/2880

Finally I found the issue, at least in my case: if no Windows HTTP proxy is specified, NuGet uses (if present) the HTTP Proxy specified in the environment variable http_proxy.

Although, I had the http_proxy set even before, NuGet worked fine. So, an update should have triggered the issue.

Thanks anyone who viewed the question.

like image 50
Wickramaranga Avatar answered Oct 02 '22 08:10

Wickramaranga