Create and publish a package

It's a simple process to create a NuGet package from a .NET Class Library and publish it to The following steps walk you through the process using the NuGet command-line interface (CLI) and Visual Studio:

Install pre-requisites

  1. Visual Studio 2015. Install the Community edition for free from; you can use the Professional and Enterprise editions as well.
  2. NuGet CLI. Download the latest version of nuget.exe from, saving it to a location of your choice. Then add that location to your PATH environment variable if it isn't already.

nuget.exe is the CLI tool itself, not an installer, so be sure to save the downloaded file from your browser instead of running it.

Create a class library project

In Visual Studio, choose File > New > Project, expand the Visual C# > Windows node, select the "Class Library" template, name the project AppLogger, and click OK.

Create new class library project

Right-click on the resulting project file and select Build to make sure the project was created properly.

Within a real NuGet package, of course, you'll implement many useful features upon which others can build applications. For this walkthrough, however, you won't write any additional code because a class library from the template is sufficient to create a package.

Create the .nuspec package manifest file

Every NuGet package needs a manifest–a .nuspec file–to describe its contents and its dependencies. The NuGet CLI creates this file for you, which you then customize.

  1. Open a command prompt and navigate to the folder containing the AppLogger project file (.csproj).
  2. Run the NuGet CLI spec command to generate AppLogg.nuspec:

    nuget spec
  3. Open the file in your favorite text editor. It will look something like the code below, where tokens in the form $<token>$ will be replaced during the packaging process with values from the project's Properties/AssemblyInfo.cs file. For more details on tokens, see Creating a .nuspec file.

    <?xml version="1.0"?>
        <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
        <copyright>Copyright 2016</copyright>
        <tags>Tag1 Tag2</tags>
  4. Select a package ID that is unique across We recommend using the naming conventions described in Creating a package. Be sure to update the author and description tags or you will get an error in the next step. Here's an updated .nuspec file as an example:

    <?xml version="1.0"?>
        <description>Awesome application logging utility</description>
        <releaseNotes>First release</releaseNotes>
        <copyright>Copyright 2016</copyright>
        <tags>application app logger logging logs</tags>

For packages built for public consumption, pay special attention to the <tags> element, as these tags help others find your package and understand what it does.

Create the package

Creating a NuGet package from a project is simple: just run the pack command:

nuget pack AppLogger.csproj

This creates a NuGet package file like AppLogger. using the package name and version number from the .nuspec file.

Note that you'll get warnings if you haven't updated various fields in the .nuspec file from their default values.

Publish the package

You're now ready to publish the package to using the NuGet CLI. (Alternately, you can use the publishing workflow.


The packages you publish to are publicly visible to other developers. To host packages privately, see Hosting packages.

  1. Create a free account on, or log in if you already have one. When creating a new account, you'll receive a confirmation email . You must confirm the account before you can upload a package.
  2. Once logged in, click your user name (on the upper right) to navigate to your account settings.
  3. Under API Key, click copy to clipboard to retrieve the access key you'll need in the CLI:

    Copying the API key to the clipboard


Always keep your API key a secret! If your key is accidentally revealed, you can always regenerate it at any time. You can also remove the API key if you no longer want to push packages via the CLI.

  1. At a command prompt, run the following command, replacing the key with the value copied in step 3:

    nuget push AppLogger. 47be3377-c434-4c29-8576-af7f6993a54b -Source
  2. You should then see something like the following:

    Pushing AppLogger. to ''...
        Created 6829ms
    Your package was pushed. 
  3. In your account on, click Manage my packages to see the one that you just published; you'll also receive a confirmation email. Note that it might take a while for your package to be indexed and appear in search results where others can find it. During that time your package page will show the message below:

    This package has not been indexed yet. It will appear in search results and will be available for install/restore after indexing is complete.


Virus scanning: All packages uploaded to are scanned for viruses and rejected if any viruses are found. All packages listed on are also scanned periodically.

And that's it! You've just created and published your first NuGet package to, that other developers can use in their own projects.