NuGet is the package manager for the Microsoft development platform including .NET. The NuGet client tools provide the ability to produce and consume packages. The NuGet Gallery is the central package repository used by all package authors and consumers.

This post will create you how to create and publish your own NuGet package.

Let’s begin by downloading NuGet. NuGet is included in Visual Studio 2010, 2012 and 2013 extension manager. But I recommend you downloading the command line utility. I would then copy the file to C:Windows folder to be able to use it anywhere.

Let’s now create our package.

Begin by signing up on NuGet.org and retrieving your API Key. This will be required when you want to push your package through command line. If you want, you can also upload your package on their site.

  • Open up command prompt, type in nuget setApiKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx where the xx’s are your API Key.

  • Next cd into your project folder. Then type nuget spec YourProject.csproj. That creates a .nuspec file with info about your package. If you don’t edit that file, NuGet will automatically fetch required information from your program’s AssemblyInfo.cs file.

  • Next type nuget pack YourProject.csproj. That creates a .nupkg file with your NuGet package. It specifies the version in the filename, so it can be updated later on with newer versions.

  • Next type nuget push NuGetPackageName.nupkg where you specify the name of your NuGet package (.nupkg in your project directory). This pushes your NuGet package to NuGet Gallery online.

You’re all done!

When you update your project, you create a new NuGet package and push it like mentioned before. NuGet will automatically update your package online.