Create a NuGet package in 5 minutes

1. Register for a NuGet account to get your Access Key needed for deploying your NuGet Package to the public repository.

2. Install NuGet.

3.  Then download the NuGet.exe command-line utility.

4.  Create a .nuspec file

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata >
    <id>MarrDataMapper</id>
    <version>1.0.0</version>
    <authors>Jordan Marr, Rick Schott(NuGet)</authors>
    <requireLicenseAcceptance>true</requireLicenseAcceptance>
    <description>Marr DataMapper provides a fast and easy to use wrapper around ADO.NET that enables you to focus more on your data access queries without having to write plumbing code.</description>
     <language>en-US</language>
    <projectUrl>http://marrdatamapper.codeplex.com/</projectUrl>
    <licenseUrl>http://marrdatamapper.codeplex.com/license</licenseUrl>
    <tags>ORM</tags>
  </metadata>
  <files>
     <file src="binDebug*.dll" target="lib" />
  </files>
</package>

5. Pack your NuGet package from the command-line:

NuGet.exe pack marrdatamapper.nuspec -b "path to your project"  -o "path for output of generated .nupkg file"

I do mine in the post-build event like this so my .nupkg is always ready to be published:

"$(ProjectDir)NuGetNuGet.exe" pack "$(ProjectDir)NuGetmarrdatamapper.nuspec" -b "$(ProjectDir)"  -o "$(ProjectDir)$(OutDir)"

6.  The last step is to push your .nupkg file to the NuGet Gallery

nuget.exe push "..bin/debug/MarrDataMapper.1.0.0.nupkg" 99999999-9999-9999-9999-999999999999

Results:
A fresh new package in the NuGet Gallery online and the Visual Studio Package Manager.

Resources:
NuGet.org
Package Manager Console Command Reference
Creating a Package
.nuspec File Format

4 Responses to Create a NuGet package in 5 minutes

  1. Pingback: Creating an Internal NuGet Feed | coderob

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">