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.
Once you add the NuGet Packager project to your solution, you can find the project hierarchy as shown below.
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.
Copy your libraries that you would like to publish in the lib folder of the NuGet project.
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
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
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.
You can even view through NuGet package manager the package installed.
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>
That’s it you are good to go.