<<

NuGet Package Management solution for .NET.

www.scmGalaxy.com WHO AM I? Rajesh Kumar

[email protected] Agenda

 Nuget Feature Overview

 Nuget Components

 Consuming Packages

 Creating Packages

 Publishing Packages

 Hosting Your own Nuget Feed

 Nuget Community and Advanced Topics

www.scmGalaxy.com Before NuGet: third-party and OSS

 Everything points towards

 Only for those who search

 Google, Bing, CodePlex, GitHub, …

 False competition

 Microsoft things either bundled or via a neat

 Hard to integrate OSS

 Compile? Find right version? Find right dependencies?

www.scmGalaxy.com Before NuGet: sharing own code

 Shared code in source control

 Or compiled code in separate

 Separate assembly on a network share or in source control

 No versioning on the assembly file

 Update nightmare (“big solutions”)

www.scmGalaxy.com NuGet!

www.scmGalaxy.com With NuGet: third-party and OSS

 One repository: NuGet.org

 OSS and Microsoft provided libraries mixed

 Dependencies, Configuration changes, Versioning

www.scmGalaxy.com With NuGet: sharing own code

 Create a NuGet package

 Specify dependencies, enforce versioning

 Consuming project: specify version

 Updating is a joy

www.scmGalaxy.com 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

www.scmGalaxy.com What is NuGet

NuGet is the 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.

www.scmGalaxy.com What is NuGet

 Open Source Project initiated by Microsoft

 http://nuget.codeplex.com/

 Intended to solve the issues related to management of 3rd party assembly dependencies

 Microsoft Non .NET Framework stuff

 Open Source Libraries

 You own libraries!

www.scmGalaxy.com Of course it was inspired by…

RPM Package Manager

 Ruby Gems

 …

www.scmGalaxy.com NuGet in Visual Studio Releases

1/14/2011 3/30/2011 6/17/2011 12/13/2011 5/23/2012 10/4/2012 2/15/2013 6/26/2013 10/7/2013 1.0 1.2 1.4 8/30/2011 1.6 4/4/2012 1.8 6/19/2012 2.1 12/12/2012 2.2.1 4/25/2013 2.6 8/22/2013 2.7.1 2/12/2011 4/25/2011 1.5 1.7 2.0 2.2 2.5 2.7 1.1 1.3

Introduced with ASP.NET 2/28/2012 8/22/2012 4/4/2013 9/9/2013 MVC 3 Visual Studio Visual Studio Visual Studio Visual Studio and 2012 Beta 2012 RTM 2012 Update 2 2013 RC Web Pages v1 5/31/2012 6/26/2013 Visual Studio Visual Studio Visual Studio 2013 RTM 2012 RC 2013 Preview

www.scmGalaxy.com NuGet Architect Components

WCF Data # C# Services

VS Addin

Console Gallery NuGet App Server Core MsBuild Tasks Package Explorer www.scmGalaxy.com www.scmGalaxy.com 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 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

www.scmGalaxy.com NuSpec File

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

Heavywww.scmGalaxy.com 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.

www.scmGalaxy.com 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) www.scmGalaxy.com . Service (like MyGet) Visual Studio Integration (GUI - Nav)

www.scmGalaxy.com Visual Studio Integration (GUI - Install)

www.scmGalaxy.com Visual Studio Integration (GUI - Update)

www.scmGalaxy.com Visual Studio Integration (GUI - Settings)

www.scmGalaxy.com Visual Studio Integration (GUI - References)

www.scmGalaxy.com VS (Package Management Console)

Powershell with some loaded modules.

Allowswww.scmGalaxy.com specific version installation as well as uninstall. Setup on Command Line

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

www.scmGalaxy.com Powershell Commands

 Get-Package -ListAvailable

 Install-Package {packageid}

 Remove-Package {packageid}

www.scmGalaxy.com Get into Nuget World

 nuget install automapper

www.scmGalaxy.com From where package is coming?

 https://www.nuget.org/

www.scmGalaxy.com 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] www.scmGalaxy.com . When packages are in the gallery you can update to latest version Ecosystem (flow)

GitHub CodeDrop . Versions Source . Versions . Versions Builds Files Deployments

Developer NuGet www.scmGalaxy.com Server . Versions Dlls Ecosystem (dependencies)

The CI solution is the single abstraction point to the CodeDrop which is only depended on by servers to be deployed

Note the symmetry between the developer www.scmGalaxy.comand the CI solution Hosting Your Own Repository

 Folder / File share  NuGet.Server package  NuGet Gallery – www..com/nuget/nugetgallery  MyGet – www.myget.org

www.scmGalaxy.com Automate deployments

 Build results in .nupkg

 Octopus deploys to its tentacles

 Test tentacles

 Staging tentacles

 Production tentacles

 www.octopusdeploy.com

www.scmGalaxy.com Create a packages

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

www.scmGalaxy.com Hosting your own Repository in Nuget

www.scmGalaxy.com Hosting your own Nuget Feed?

www.scmGalaxy.com Limitation of

www.scmGalaxy.com www.scmGalaxy.com www.scmGalaxy.com www.scmGalaxy.com www.scmGalaxy.com www.scmGalaxy.com www.scmGalaxy.com www.scmGalaxy.com Resources

 NuGet Source – http://nuget.codeplex.com/

 NuGet Public Gallery - http://www.nuget.org/

 MyGet – Private Gallery as a service - https://www.myget.org/

 Author: Lawson Caudill – http://www.getthinktank.com

www.scmGalaxy.com Where do I get it?

 VS Addin: NuGet Package Manager  http://visualstudiogallery.msdn.microsoft.com/en-us/27077b70-9dad-4c64-adcf- c7cf6bc9970c  Console App  http://nuget.codeplex.com/  MsBuild Tasks  http://nuget.codeplex.com/  NuGet Explorer  http://nuget.codeplex.com/

 Gallery Server  http://galleryserver.codeplex.com/

www.scmGalaxy.com Appendix - Chocolatey

 NuGet

 developer packages

 Chocolatey

 applications and tools packager

 “” or “-get” for Windows

 www.chocolatey.org

www.scmGalaxy.com Appendix - Many, many, many

NuGet Project  Nexus support for NuGet

 NuGet-based tools by Microsoft  Glimpse Plug-ins

 NuGet Package Explorer  ReSharper Plug-ins

 MyGet (NuGet-as-a-Service)  Orchard

 Chocolatey  NuGetMustHaves

 OctopusDeploy  NuGetFeed

Deployment Manager  NuGetLatest

 SymbolSource  NuGet server in

 ProGet (Inedo)  NuGet Fight

 CoApp  NuGit  BoxStarter   see  SharpDevelop NuGet plug-in http://docs.nuget.org/docs/reference  NuGet plug-in /ecosystem

 TeamCity support for NuGet

 Artifactory support for NuGet

www.scmGalaxy.com