How to Add a New NuGet Package Source in Visual Studio (Step-by-Step Guide)
Learn how to add a custom NuGet package source in Visual Studio using local paths, UNC shares, or private feeds. Follow this step-by-step guide to configure NuGet sources globally and improve your .NET development workflow.
Adding a custom NuGet package source in Visual Studio is essential when working with private feeds, local folders, or network shares. Whether you're using internal packages, testing offline builds, or accessing secure third-party feeds, Visual Studio makes it easy to manage multiple NuGet sources.
This guide walks you through the steps to add a new NuGet package source in Visual Studio, including configuration tips and use cases.
What Is a NuGet Package Source?
A NuGet package source is a location from which Visual Studio retrieves .nupkg
packages during development. These sources can be:
- Public repositories like
nuget.org
- Internal feeds hosted on-premise or on the cloud (e.g., Azure Artifacts)
- Local or shared folders for testing and offline access
How to Add a New NuGet Package Source in Visual Studio
Step 1: Open the NuGet Package Manager
- Open your solution in Visual Studio.
- Right-click the Solution node in the Solution Explorer.
- Select Manage NuGet Packages for Solution.
Step 2: Open the NuGet Sources Settings
- In the top-right corner of the NuGet Manager, click the gear icon ⚙️ labeled
Package Sources
.
Step 3: Add a New Source
In the Options window:
- Click the
+
button to create a new source. - Provide a Name (e.g.,
MyInternalFeed
,LocalNuget
). - Enter the Source Path:
- A URL (e.g.,
https://myfeed.company.com/nuget
) - A UNC path (e.g.,
\\Server\NuGetPackages
) - A local folder (e.g.,
C:\Packages\NuGet
)
- A URL (e.g.,
- Click Update or OK to save the new source.
Where Are NuGet Sources Saved?
When you add a new source through the Visual Studio UI, it is saved globally for the current user in the NuGet configuration, typically located at:
%APPDATA%\NuGet\NuGet.Config
This means:
- All projects in Visual Studio will have access to the new source.
- The setting applies only to the current user on that machine.
Common Use Cases for Custom NuGet Sources
- Private NuGet Feeds in enterprise environments
- Local testing with pre-release or experimental packages
- Offline development when internet access is limited
- Custom feeds hosted on services like GitHub Packages or Azure Artifacts
Tips for Managing NuGet Sources
- To edit or remove a source, return to the Package Sources window and select the desired entry.
- For team environments or CI/CD pipelines, include a custom
nuget.config
file in your solution or repository to define shared sources. - You can also use the CLI command:
nuget sources add -name "MyFeed" -source "https://your-feed-url"
Conclusion
Managing NuGet sources in Visual Studio gives you full control over where your .NET projects retrieve packages. Whether you're using internal feeds, testing local builds, or ensuring secure package delivery, setting up a custom NuGet source is quick and easy.
Stay efficient and secure—configure your NuGet sources the right way.