how to add extra package source in NuGet packages?

Firdavs Muzaffarov 40 Reputation points
2025-10-21T09:03:10.9933333+00:00

I usually use public NuGet packages only. But, I am going to install packages from private source in my project.
How can I configure/use both private and public packages source by Visual Studio?

Developer technologies | Visual Studio | Extensions
0 comments No comments
{count} votes

Answer accepted by question author
  1. Azizkhon Ishankhonov 925 Reputation points
    2025-10-21T09:12:35.3366667+00:00

    To use both public and private NuGet package sources in your Visual Studio project, you need to configure NuGet to recognize both sources. Here’s how you can do it:

    1. Open NuGet Package Manager Settings

    • In Visual Studio, go to Tools > Options.
    • Expand the NuGet Package Manager section and click on Package Sources.

    2. Add Your Private Package Source

    • Click the "+" button to add a new package source.
    • Enter a Name (e.g., "My Private Source").
    • Enter the Source URL or local path to your private NuGet feed.
    • Click Update to save.

    3. Ensure Both Sources Are Active

    • Make sure both the official NuGet source (https://api.nuget.org/v3/index.json) and your private source are listed and checked/enabled.

    4. Installing Packages

    When you open the Manage NuGet Packages dialog for your project, you can select which source to use from the Package source dropdown at the top. If you search for a package, Visual Studio will query all enabled sources. If packages with the same name exist in both, you can select the desired version/source.

    5. Using nuget.config (Optional)

    For source control or automation, you can define sources in a nuget.config file:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
        <add key="MyPrivateSource" value="https://your-private-feed-url/" />
      </packageSources>
    </configuration>
    
    • Place nuget.config in your solution folder or user profile folder (%appdata%\NuGet\).
    • Visual Studio and dotnet CLI will use these sources automatically.

    6. Authenticating to Private Feeds

    If your private source requires authentication, Visual Studio will prompt you for credentials the first time you access it. For Azure Artifacts feeds, you may need to sign in with your Azure account.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.