PM's Blog

Pramod Mohanan's notes about ASP.NET, MVC, C#, SQL, jQuery, Bootstrap

Creating a Nuget Repository Server

In my previous blog post I wrote a step-by-step guide on how we can create a NuGet Package using Visual Studio. This one explains how to create a Nuget Server that can then be used as an additional Package source in NuGet. This repository will contain only the packages that you add and is often used a private repository by developers.

Create an empty ASP.NET application
In visual studio, create an empty ASP.NET application

select emtpy project template

Add NuGet.Server package to the project
Using NuGet Package manager or console add the package NuGet.Server by .NET Foundation to the project. Project and details here

Once this is added to your project, the application is almost all set to become a Nuget repository server. It handles the storage and serving of packages based on request from Nuget package manager/console. If we run the project now, we see the following page

The URL http://localhost:63628/nuget can now be added a package source in NuGet. We will get there shortly but before that lets add a package to the repository we created.

Adding a package to our repository server
The project now has a Packages folder where the .nupkg files can be added. NuGet server will then automatically copy the package to the correct location, does the extracting etc.
The below screen shot where I am dropping my package in that folder

and once the extracting is done automatically( you may have to access the above URL again) and the package is ready the folder would look like

Great! so we have a Nuget Repository server with one package in it now. Lets go ahead and configure NuGet to use our repository as a package source

Using our Repository
First lets add the our URL as a package source in NuGet Package Manager settings in Visual studio

Accessing packages in our Repository via NuGet Package Manager
Select our repository as the package source in the dropdown (normally on the top right) which will then list all packages available in our repository. All other functionality (version listing, install, uninstall etc) of Nuget Package Manger will work for our packages too.


Leave a Reply

Your email address will not be published. Required fields are marked *

PM's Blog © 2018