Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Package Manager: "No packages found" even though the package exists

After updating Visual Studio to 2015 Update 2 I kept getting a "No packages found" error in NuGet Package Manager, despite browsing/searching for packages that I knew existed and which could be added from the Package Manager Console.

This is frustrating as the NuGet site clearly shows the packages are available. As a workaround I can install them via the Package Manager Console - but the GUI just shows "No packages found".

like image 837
Stelloy Avatar asked May 18 '16 07:05

Stelloy


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 allow NuGet to download missing packages?

To do that, go to Tools, NuGet Packaged Manager, then go to Package Manager Settings. Go to the General section, and then make sure you have a checkmark for Allow NuGet to download missing packages and also to automatically check for missing packages during the build in Visual Studio. So click on OK.

What is the .NuGet folder?

The global-packages folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder.


2 Answers

As of VS2015 Update 2 the default and only feed installed is MS-Curated "Microsoft and .NET", https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/

This feed is missing a LOT of commonly used packages.

You can resolve this by simply adding the "normal" NuGet feed with all packages:

  1. Open Visual Studio 2015 as admin
  2. Tools > Options
  3. NuGet Package Manager > Package Sources
  4. Click the green "add" icon, and add the following feed:

    NuGet: https://api.nuget.org/v3/index.json

like image 178
Stelloy Avatar answered Sep 27 '22 22:09

Stelloy


Here are the troubleshooting steps I would take when looking into this issue.

  1. Visual Studio Settings
    • Make sure you are in the BROWSE section.
    • Click on the Package Source drop down to the right.
      • Make sure nuget.org is listed.
        • If nuget.org is not listed, add it.
          • Open Tools > Options (Options window will open)
          • Locate NuGet Package Manager > Package Sources
          • Under available sources, click the + icon.
          • Enter NuGet.org as the package name
          • Enter https://api.nuget.org/v3/index.json as the package source.
          • Click the OK button to save changes.
      • **IMPORTANT** Choose ALL as your package source to search all sources.

enter image description here

  1. Connectivity & DNS

    • Make sure internet is connected
      • Open CMD
      • ping 8.8.8.8
        • If this does not respond your internet is not connected
      • ping api.nuget.org
        • If this does not resolve to an IP, then you have a DNS issue.
      • nslookup api.nuget.org 8.8.8.8
        • This should list the same IP address as the ping (along with some other info), If it does not then you may have a DNS issue (some local ISP DNS servers are not very good). Try changing your internet connection's DNS server to 8.8.8.8 and trying again.
  2. Proxy Issue

    • Do you have Fiddler open? This can interfere with your connection to the nuget repository. Try shutting it down.
    • Did you set all .NET to run through a proxy? This is a common step taken in troubleshooting if you need to see all requests coming in.
      • Open C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
      • Remove or comment out the proxy configuration

Proxy Config Section

<system.net>
<defaultProxy enabled = "true" useDefaultCredentials = "true">
<proxy autoDetect="false" bypassonlocal="false" 
proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
</defaultProxy>
</system.net>
like image 35
Tom Gordon Avatar answered Sep 27 '22 23:09

Tom Gordon