Tuesday, November 12, 2013

Creating NuGet package using NuGet Package Explorer

There are several different ways to create Nuget package for your component or library.

  • Using Visual Studio (version 2010 and above) project.
  • Through command-line, using Nuget.exe tool

This tutorial will give you a detailed step-by-step description for the last option: NuGet Package Exporer.
So, let's start.

1. First of all you need to download and install NuGet Package Exporer.

2. When installation is completed - run Nuget Explorer and select Create a new package option.

Nuget Explorer start screen

3. Click on the Edit metadata button at the top of Package metadata panel to enter package name, version, description and other parameters.

4. Then add Lib folder to your package (Content > Add > Lib Folder menu item) - this is the place where your assemblies will be stored.

5. Right click on "Lib" folder and select Add .NET folder and then select the version of .NET framework. Repeat this operation for all versions of .NET you have assemblies for.

 6. Then right click on each .NET folder, select Add Existing Files menu item and select the assemblies (DLLs) for corresponding version of .NET.
The main rule: all files placed into some lib\netXX folder will be added as references to the targeting project with corresponding target platform (lib\net35 - for .NET 3.5 projects, lib\net40  - for .NET 4.0, etc).

7. PowerShell scripts
You can also add power shell scripts which will be executed on package install (install.ps1 script) or each time when solution is opened (init.ps1).
To do it use Content > Add > Tools  menu item and then right click on tools folder in right panel and select Add install.ps1 or Add init.ps1 menu item.

Finally  - save the package and close NuGet Package Explorer. You package will be saved as PackageName.1.0.0.nupkg file.

In our next article we are going to describe how to test you NuGet package locally using Visual Studio.