There are times far and in between where I need to publish a .NET library under a the nuget distribution. However, many times I need to google around trying to find a good example of how to do it.
I am going to self document to the rest the simple step on getting your nuget package published
How to Publish a Nuget Package
1. Setup and Prep Project (skip if you have already done this)
- Create a Nuget.org
- Download and install NuGet Package Explorer. For Windows 8 Go Here
- Download and install Visual Studio Nuget Package Manager Extension
- Right Click on your solution file in Solution Explorer and select Enable NuGet Package Restore
2. Create Your .nupkg File
Use your Nuget.exe tool to generate a .nupkg containing the the .nuspec information
Open a command windows and navigate to your the project file folder. Depending on the relative location of your Nuget.exe file you will want to execute this command:
(This assumes my .nuget directory is located one directory down from my project file)
This will create the following file.
You can use the NuGet Package Explorer you installed earlier to make any changes the NuGet.exe tool got wrong. Simply double click on the .nupkg file to open NuGet Package Explorer, Click “Edit” –> Click “Edit Metadata”.
3. Publish Your .nupkg file
You can publish using your NuGet Package Explorer or command line like this:
../.nuget/nuget.exe setApiKey 00000000-0000-0000-0000-000000000000 ../.nuget/nuget.exe push MSample.Nuget.Package.22.214.171.124.nupkg
For you UI junkies (like me) using NuGet Package Explorer is just as easy. Click “File” –> Click “Publish”. Supply your API Key/Publish Key and Publish.
NOTE: If you haven’t already You will need to go to your Nuget Account page to acquire your API Key/Publish Key.
Comment below if you have any suggestion or incite with your experience with Nuget Publishing