NuGet

Package Management solution for .NET

By - scmGalaxy.com

About Me !

Agenda

  • Nuget Feature Overview
  • Nuget Components
  • Consuming Packages
  • Creating Packages
  • Publishing Packages
  • Hosting Your own Nuget Feed
  • Nuget Community and Advanced Topics

Before NuGet: third-party and OSS

  • Everything points towards Microsoft
  • Only for those who search
    • Google, Bing, CodePlex, GitHub, ...
  • False competition
    • Microsoft things either bundled or via a neat installer
  • Hard to integrate OSS
    • Compile? Find right version? Find right dependencies?

Before NuGet: sharing own code

  • Shared code in source control
  • Or compiled code in separate assembly
  • Separate assembly on a network share or in source control
  • No versioning on the assembly file
  • Update nightmare ("big solutions")

NuGet!

With NuGet: third-party and OSS

  • One repository: NuGet.org
  • OSS and Microsoft provided libraries mixed
  • Dependencies, Configuration changes, Versioning

With NuGet: sharing own code

  • Create a NuGet package
  • Specify dependencies, enforce versioning
  • Consuming project: specify version
  • Updating is a joy

What is Packages?

  • A package is a bundle of something you want to reuse.
    • It can have dependencies to other packages.
    • It can contain files:
      • Assemblies
      • Content
      • Tools

What is NuGet

NuGet is the package manager solution for the Microsoft development platform.

The NuGet client tools provide the ability to produce and consume packages.

The NuGet Gallery is a central package repository used by all package authors and consumers.

  • Open Source Project initiated by Microsoft
  • Intended to solve the issues related to management of 3rd party assembly dependencies
    • Microsoft Non .NET Framework stuff
    • Open Source Libraries
    • You own libraries!

Of course it was inspired by...

  • Linux RPM Package Manager
  • Ruby Gems
  • ...

NuGet in Visual Studio Releases

NuGet Architect Components

Components

  • NuSpec
    • Xml file containing the specification to be packaged
  • NuGet.Core
    • NuGet.Core is the core framework assembly for NuGet that the rest of NuGet builds upon.
  • NuPkg
    • Zip file containing the package contents, [un]install scripts, and NuSpec
  • NuGet Gallery
    • Hosted website to serve up latest or specific versions of packages (NuPkg)
  • NuGet VS Extension
    • Visual Studio Plugin to allow installation of packages
  • Nuget.exe
    • Command line application for installing packages and managing gallery

NuSpec File

This is a trivial example, you can also have specialized install and uninstall scripts referenced for complicated projects (i.e. jQuery).

Heavy use of convention in absence of declarative!

NuPkg File

This is a simple type of package so in absence of special logic NuGet will be add a reference pointing at the matching framework dir to the csproj in question.

Gallery

The public gallery is good for openly shared code.

You can also host private galleries and configure them locally.

NuGet will check both locations for referenced packages...

Private can be done:

  • Local folder based
  • Small version (no DB)
  • Full version (requires DB)
  • Service (like MyGet)

Visual Studio Integration (GUI - Nav)

Visual Studio Integration (GUI - Nav)

Visual Studio Integration (GUI - Install)

Visual Studio Integration (GUI - Install)

Visual Studio Integration (GUI - Update)

Visual Studio Integration (GUI - Settings)

Visual Studio Integration (GUI - References)

VS (Package Management Console)

Powershell with some loaded modules. Allows specific version installation as well as uninstall.

Setup on Command Line

http://docs.nuget.org/consume/installing-nuget

Powershell Commands

  • Get-Package -ListAvailable
  • Install-Package {packageid}
  • Remove-Package {packageid}

Get into Nuget World

  • nuget install automapper

From where package is coming?

https://www.nuget.org/

NuGet.exe (command line interface)

  • nuget.exe help [feature (i.e. pack)]
    • Help lists commands and can be combined with a command to get info
  • nuget.exe pack [PackageID].nuspec -version 1.1.0.0
    • First the NuSpec is used to construct the package file via the 'pack' stage
  • nuget.exe push [PackageID].nupkg [API Key] -Source [Gallery]
    • Next the created NuPkg is loaded into the appropriate gallery via the 'push' stage
  • nuget.exe install [packages.config file OR package id]
    • When packages are in the gallery you can install them locally
  • nuget.exe update [solution file OR project file]
    • When packages are in the gallery you can update to latest version

Ecosystem (flow)

Ecosystem (dependencies)

Hosting Your Own Repository

Automate deployments

  • Build results in .nupkg
  • Octopus deploys to its tentacles
    • Test tentacles
    • Staging tentacles
    • Production tentacles
  • www.octopusdeploy.com

Create a packages

http://reasoncodeexample.com/2012/04/29/creating-a-nuget-package/

Hosting your own Repository in Nuget

Hosting your own Nuget Feed?

Limitation of

Resources

Where do I get it?

Appendix - Chocolatey

  • NuGet
    • developer library packages
  • Chocolatey
    • applications and tools packager
    • "yum" or "apt-get" for Windows
  • www.chocolatey.org

Appendix - Many, many, many

  • Outercurve Foundation NuGet Project
  • NuGet-based tools by Microsoft
  • NuGet Package Explorer
  • MyGet (NuGet-as-a-Service)
  • Chocolatey
  • OctopusDeploy
  • RedGate Deployment Manager
  • SymbolSource
  • ProGet (Inedo)
  • CoApp
  • BoxStarter
  • SharpDevelop NuGet plug-in
  • CoApp
  • BoxStarter
  • SharpDevelop NuGet plug-in
  • Xamarin NuGet plug-in
  • TeamCity support for NuGet
  • Artifactory support for NuGet
  • Nexus support for NuGet
  • Glimpse Plug-ins

Questions ???

Thanks !!