Installing a NuGet Server | Making Module Packages

Package Explorer

The NuGet team created a great GUI tool called Package Explorer for editing packages. Head over to their how to page for a walk-through on installing and using Package Explorer, then come back here to find out how to configure a package for compatibility with PS-NuGet.

PowerShell Modules in PS-NuGet Packages

PS-NuGet tries to borrow as much as possible from the main NuGet projects, where it fits in with our goal of easy module management for PowerShell. The NuGet package specification lists four special folders in a NuGet package. The PS-Nuget package only supports two of those folders, "tools" and "content".

Content

The content folder is where your module code goes. The files (and sub-folders) in this folder get copied directly into your module folder that PS-NuGet is managing. This is where you put your PSD1, PSM1, and any other supporting files your module needs.

Tools

The NuGet package specification defines three PowerShell scripts that act as event handlers for the package lifecycle. Those three scripts have been brought over to the PS-NuGet client as well and are placed in the "tools" folder in your package. All three files are optional (as is the tools folder), depending on your package's needs. The three files are automatically run based on their file names using the following conventions:

The right-click context menu in Package Explorer has options to add both a "content" and "tools" folder for you, so you don't have to remember what the correct names are. The right-click context menu on the "tools" folder also has options to add the init, install, and uninstall script files for you. The script files generated by Package Explorer include the correct parameter header for the parameters that are passed to the event scripts as defined here:

The param blocks look like this

ScriptParameters
init.ps1param($installPath, $toolsPath, $package)
install.ps1param($installPath, $toolsPath, $package, $project)
uninstall.ps1param($installPath, $toolsPath, $package, $project)


Special thanks to the Outercurve Foundation for releasing the NuGet Documentation that much of this page came from under the Creative Commons 3.0 License