Pages

How to add custom nuget package repository in Visual Studio

Wednesday, November 4, 2015

Introduction

Most of the .NET developers used nuget packages from Microsoft's nuget package repository which is set as default for the Visual Studios. But sometimes we need to create our own custom nuget packages when we need to manage large applications. Again many .NET developers used nuget packages from third party package repository like MyGet package repository. Recently Microsoft also hosted some of their nuget packages there like .NET Core library, Entity Framework 7 etc in there. So in that case we need to add those package repository at our Visual Studio to use them in our applications. You can configure both file system(local and network) or web repository to get nuget packages. In this tutorial I would like show the process of adding nuget package repository.

Prerequisite

In this tutorial I have used Visual Studio 2015 and Nuget Package Manager to show the process. But the steps should be same for other Visual Studios also.

Steps

  1. Go to Tools>Nuget Package Manager>Package Manager Settings. This will open the option window for the visual studio.
  2. From the option window expand Nuget Package Manager option and select Package Sources. This will option will show the available package sources form where Visual Studio will get the nuget packages. Click the Add button "+".
  3. After clicking the Add button, a new package source will be created which we need to edit for our custom repository. To edit the source we need to select the package and insert a name and source location where the nuget packages are resides.
  4. To set the nuget package source to a custom nuget repository, we first give it a name in the Name field and provide the url to the Source text field. In the figure shown below, we have added the myget repository location to get the nuget packages for Entity Framework 7 and others currently developed nuget packages.
  5. If we want to get nuget packages from a file system resides in our local or system file system, we need to select the "..." button next to the Source text field and browse to the folder location. Then press update button to update the source location. 


Conclusion

NuGet provide consistency, every library you need can be added with just one click. All configuration you need is automatic and any dependencies are automatic added as well. Hopefully this article will help you to customize and create your own nuget packages and use them in your application.

No comments:

Post a Comment