Fix Missing Default NuGet Feed

July 13, 2022#Software Development
Article
Author image.

Kyle McMaster, Senior Consultant

I was recently going through the process of installing the developer tooling I use on a fresh, new laptop. I installed the usual suspects like Visual Studio and Visual Studio Code as well as a few other tools I use often most of which can be found here. Once I was finished with installation, I launched Visual Studio and created a new ASP.NET Core Web API project. When attempting to build the solution I received the following NU1101 error for all of the package references telling me that the package restore had failed.

NU1101 Unable to find package Swashbuckle.AspNetCore. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages 

I opened the NuGet package manager and noticed Visual Studio only had only installed the Microsoft Visual Studio Offline Packages feed. I was missing the default Nuget.org feed.

Installed NuGet Feeds

How to fix the issue

There are three configuration files that can be used to manage the NuGet feeds available to Visual Studio. The first being a configuration file local to the application’s project and solution, a user-specific configuration file for all of a user’s projects, or a system-wide configuration affecting all users on the machine. These individual configurations have a hierarchy where project-specific feeds override a user’s configuration and user-configured feeds override any system-wide configurations. Since I needed to fix the issue for all projects I would be working with and I am the only user that will be working on this machine, I opted for modifying my user’s configuration. This is also the default file that is modified when working with the CLI tools and can be found at %appdata%\NuGet\NuGet.Config on Windows. When I first opened this file it had the following contents:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
  </packageSources>
</configuration>

As you can see, there is not much going on here. I needed to add the default feed to the packageSources section. The updated configuration is shown below.

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

After modifying the file, I restarted Visual Studio and built the solution. It worked! I am now able to use the NuGet package manager to install packages and build project moving forward. Hope this helps others affected by this or similar issues!

Additional Resources


Copyright © 2024 NimblePros - All Rights Reserved