Programming, Visual Studio

Publishing NuGet Package using NuGet Packager Extension

In one of my last post http://idevexplorer.com/2015/06/create-and-publish-nuget-package-in-windows-azure/ I have explained how we can create a NuGet Package on every build and deploy it to NuGet server in Azure.

In this post I would like to emphasize on how we can use the NuGet Package Extension in Visual Studio and publish NuGet packages to the server.

First of all we need to install the extension from the following url https://visualstudiogallery.msdn.microsoft.com/daf5c6db-386b-4994-bdd7-b6cd52f11b72. Once you have installed the extension for Visual Studio you can get the project template to create NuGet Package as shown below.

image

Once you add the NuGet Packager project to your solution, you can find the project hierarchy as shown below.

image

Now all you need to do is configure the NuGet project in order to take the libraries that you would like to publish. Open the NuGet.config file and provide the server url where the package is going to get published. Add the ApiKey which will validate the publishing of the library.

image

Copy your libraries that you would like to publish in the lib folder of the NuGet project.

image

Rename package.nuspec file to a name that you would like to distinguish for and update the project url in the nuspec file pointing to the publishing server

image

Change the description and other parameters as you want. You can even provide the dependencies to get installed or validate during the installation of the package

Now all we need to do is build the Package project. You might encounter some issues during building the package if you have renamed the nuspec file. Open NuGetPackage.ps1 file and change the following statements to point to correct NuSpec name

image

Build it again. Now you will not see any error. When you are building the NuGet project in Debug mode it will create the package *.nupkg file locally. In order to deploy it to the server through build process, you need to build it in Release mode.

Now if you go to the NuGet feed url of your server you can view the package over there.

image

You can even view through NuGet package manager the package installed.

image

If you want to delete the package from the server then you need to use the following command in Command Prompt.

nuget delete <Package Name> <Version> <API Key> –Source <NuGet Server Url>

image

That’s it you are good to go.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s