Adding packages to nuget.org

clip_image001mmmmm, nuget.

These steps were written from the mindset of adding a package to the nuget gallery on nuget.org that you require and happens to be missing. Anyone can add a package to nuget.org for any project, even if you’re not a project contributor (although that is ideal). At Russell, we use a LOT of open source frameworks. While upgrading a portion of our code today, we decided to use nuget.  The first road bump we found was that nuget.org did not have a package for Castle.Services.Transaction.  So what’s a open source loving dev gonna do then? Why, submit a package for it of course!

Steps to add a new package to nuget.org (I’m making a lot of assumptions here, such as you know how to work the command prompt):

1) Make sure you have the nuget.exe command line tool.  If not, download the latest from here (or the complex site here) and stick it somewhere accessible from your path (I use d:\dev\tools). If you already have nuget.exe, you can run ‘nuget update’ to get the latest version. More details here from David Ebbo

2) Download the released version of the package you want to add, in this example I’m using Castle.Services.Transaction, which I downloaded from http://www.castleproject.org/castle/download.html

3) Create an empty folder for the package, such as Castle.Services.Transaction, then create a subfolder called ‘lib’

4) Drop the binaries inside the lib folder. Since Castle.Services.Transaction has a NET35 and NET40 version, you’ll have multiple folders:
clip_image003

5) Delete ALL dependencies in the lib folder.  Castle.Services.Transaction depends on Castle.Core, but you do not want to include these in this package since Nuget handles dependencies for you.  The only binaries you want to include will be the binaries specifically for the project.

6) Create the manifest file by running the nuget spec command, with the –a [assembly location]. You’ll want to make sure you’re NOT inside the folder you created for this project. The .nuspec file will be created in your current folder.
clip_image005

7) Open the nuspec manifest and add the missing information. The Castle.Services.Transaction manifest is at the end of this email.

8) Now we get to generate the actual package. Run the nuget pack command, the first parameter is the .nuspec manifest, the –b parameter is the folder you created for the project, and the –o parameter is the output folder for the package. The –v parameter is for verbose output:
clip_image007

9) Login to nuget.org, and click on “Contribute”, then “Add New Package”

10) Upload the .nupkg file that we just generated with nuget pack.
clip_image009

11) Verify the details of the package then click Next:
clip_image011

12) Choose a logo, or just click Finish to use the icon taken from the manifest:
clip_image013

13) Then, hopefully, a successful upload:
clip_image015

14) After a few minutes, you package should show up:
clip_image017

That’s all there is to it.  More information on creating packages can be found here: http://nuget.codeplex.com/documentation?title=Creating%20a%20Package and Phil Haack’s post, which is a little more verbose than these simple instructions.

The Castle.Services.Transaction manifest:


<?xml version="1.0"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
 <id>Castle.Services.Transaction</id>
 <version>2.5.0</version>
 <title>Castle.Services.Transaction</title>
 <authors>Castle Project Contributors</authors>
 <owners>Castle Project Contributors</owners>
 <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
 <projectUrl>http://www.castleproject.org/services/transaction/</projectUrl>
 <iconUrl>http://www.castleproject.org/images/cp_logo32.png</iconUrl>
 <requireLicenseAcceptance>false</requireLicenseAcceptance>
 <description>Castle.Service.Transaction was inspired by the Java Transaction API (JTA), although it is a simplified version with no support for two phase commit.

Basically there is a transaction manager that is able to create transactions, that are associated with the thread. You can only have one active transaction per thread.

The transaction object only orchestrates the resources enlisted with it. It is up to the resource implementation to provide integration with some external transaction-capable entity, typically a database connection.</description>
 <dependencies>
 <dependency id="Castle.Core" version="2.5.1" />
 </dependencies>
 </metadata>
</package>

About these ads
  1. #1 by mynkow on January 28, 2011 - 12:22 am

    Of topic: How you made the color for your cmd’s text?

  2. #3 by henrik on August 16, 2011 - 11:57 am

    Retrospective thanks for that :)

  1. Tweets that mention Adding packages to nuget.org « codingreflection.com -- Topsy.com
  2. Introducing Chewie for nuget « Ang3lFir3 – Life as a Code Poet
  3. Cuttin’ Teeth With NuGet « Composite Code

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 887 other followers

%d bloggers like this: