How to Add a NuGet Package Source via Command Line
Adding NuGet Package Source via Command Line
Introduction
NuGet is the package manager for the .NET platform that allows you to install, manage, and update libraries for your projects. By default, NuGet fetches packages from the official NuGet gallery, but sometimes you may need to add a custom package source. In this article, we’ll explore how you can add a NuGet package source using the command line.
Step 1: Open Command Prompt
First, you need to open the Command Prompt on your Windows machine. You can do this by pressing the Windows key, typing “cmd,” and hitting Enter.
Step 2: Add the Package Source
Use the following command to add a package source:
nuget sources Add -Name YourSourceName -Source http://your-source-url
Replace “YourSourceName” with the name you want to give to your package source and “http://your-source-url” with the URL of your custom package source.
Step 3: Verify the Addition
To ensure that the package source was added successfully, you can list all the registered package sources by running:
nuget sources List
Conclusion
Adding a NuGet package source via the command line is a straightforward process that allows you to access packages from custom sources seamlessly. By following the steps outlined in this guide, you can efficiently manage your package sources and streamline your development workflow.
Additional Tips
- Make sure the URL you provide for the package source is correct and accessible.
- You can also remove a package source using the
nuget sources Remove
command. - Keep your package sources organized to easily switch between them as needed.