O'Reilly logo

Professional ASP.NET MVC 3 by K. Scott Allen, Brad Wilson, Phil Haack, Jon Galloway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Packages

Although consuming packages is very easy with NuGet, there wouldn't be any packages to consume if people didn't also create them. This is why the NuGet team is focused on making sure that creating packages is as simple as possible.

Before you create a package, make sure to download the NuGet.exe command-line utility from the NuGet CodePlex website at http://nuget.codeplex.com/. Copy NuGet.exe to a more central location on your hard drive and add that location to your PATH environment variable.

NuGet.exe is self-updatable via the Update command. For example, you can run:

NuGet.exe update

or use the short form:

Nuget u

to back up the current version of NuGet.exe by appending the .old extension to it and replace it with the latest version of NuGet.exe.

Once you have NuGet.exe installed, creating a package requires three main steps:

1. Organize the package contents into a convention-based folder structure.

2. Specify the metadata for the package in a .nuspec file.

3. Run the NuGet.exe Pack command against the .nuspec file.

Install-Package NuGet.CommandLine

Folder Structure

By default, the NuGet Pack command recursively includes all the files in the folder where the specified .nuspec file is located. It is possible to override this default by specifying the set of files to include within the .nuspec file.

A package consists of three types of files as outlined in Table 10.1.

Table 10.1: Package File Types

Folder Description
lib Each assembly (.dll

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required