How to create a nuget package on each Visual Studio build with NuPack

0
38

Introduction

Nuget is a good way to distribute libraries and even more, it exist a bunch of UI and command line to manage nuget package. I used to execute command line to produce automatically nuget package from project or solution but it is limited to most common pattern (library packaging). I often use Nuget Package Explorer to create and update my nuget package because it allows you to manipulate package as your needs. Unfortunatly, it is very non productive to edit manually a nuget package when it is often done. That’s why it can be interesting to use a nuget package like NuPack to do the job.

NuPack

NuPack is a nuget package for .NET 4.0+ that add an additional build step to pack output of project into a nuget package.

Automatic

NuPack create automatically a nuget package on each build with assembly name as id. It can work with 2 templates : 

  • Library : pack a library assembly in lib folder and declare automatically dependencies

Reference NuPack from nuget.org

          

Define assembly attribute to provide clean metadata  

NuPack nuget package creation on build project

 NuPack nuget package creation observed with Nuget Package Explorer

  • Console : pack the console as util and provide a build step through .targets file to call console application with 2 arguments : project location (csproj) and configuration (debug/release)

Automatic nuget package from console application observed with Nuget Package Explorer

Manual

NuPack detect .nuspec file when it is part of project and simple respect the specification to create the expected nuget package.

Reference

Nuget : https://www.nuget.org/packages/NuPack

Github : https://github.com/Virtuoze/NuPack

Conclusion

There are many way to create a package nuget, NuPack is one of them and can be usefull in some scenario. It is easy to use without any effort and can help to keep your nuget package up to date as soon as possible without deploying a white elepant.

LEAVE A REPLY