Download presentation
Presentation is loading. Please wait.
1
NuGet Sweet, but not edible Chris Alcock @calcock http://TheMorningBrew.NET/
2
Shameless Plug… http://TheMorningBrew.NET Daily.NET news from the Blog’o’sphere: – Latest Software Releases – Best Articles – UK Community news
3
Agenda What is NuGet, What’s it all about? Using NuGet as a package consumer Creating your own packages – Simple Package creation – Advanced Package creation Embracing the Package Manager Console Configuring package sources
4
What Is NuGet?.NET Package Manager Originally Nu / NuPack, renamed to NuGet Shipped With ASP.NET MVC3 Open Source – Part of Outercurve Foundation, hosted on CodePlex In Top 5 New Open Source Project to Watch 2010 Currently version 1.3 http://www.nuget.org http://www.outercurve.org http://nuget.codeplex.com
5
Package Management?!?!? Tools to make it easy to obtain, install and update libraries Influenced by other Package Managers: – Apt-Get - Linux – Gems - Ruby – HornGet -.NET Other.NET Packages Managers exists – OpenWrap
6
How NuGet Helps… Makes getting and installing packages easy Nice IDE Integration Provides means of finding and distributing packages Deals with more than just.NET assemblies Supports projects targeting different runtime versions and platforms Rich installation and scripting support
7
Package Gallery http://www.nuget.org Provides official source of NuGet Packages Package publishing, ownership and community functions Package Stats – http://stats.nuget.orghttp://stats.nuget.org
8
Demonstration Using NuGet as a package consumer (GUI)
9
Demonstration Installing & Uninstalling Packages via Console
10
Packaging Your Wares Steps: – Write your library / Code – Define Package Specification, Files to be included, etc – Build the package – Publish – Consume Shortcuts and Tooling makes some of this easy
11
Packaging Your Wares Can’t do it with the Extension alone Get NuGet.Exe from CodePlex NuGet Package Explorer is also really useful Both available from http://nuget.codeplex.com/releases http://nuget.codeplex.com/releases
12
Parts of NuGet Package NuGet Packages can contain: – Assemblies – Content Files – Configuration – Scripts Uses convention over configuration
13
Other Uses for Packaging Nuget isn’t just useful for distributing.NET Assemblies Can also package: – JavaScript libraries – Samples – Scripts Any Tools or files are possible
14
Demonstration Making a Package (or 2)
15
So What Else? NuGet Package Console IS PowerShell Gives easiest way to do command line operations on your VS projects PowerShell’s inclusion provides scripting capabilities for packages
16
Demonstration Package Management Console OR PowerShell Console
17
PowerShell In Packages 3 Special PowerShell Scripts in NuGet – Init.ps1 – Install.ps1 – Uninstall.ps1 Scripts located in Tools package folder Have access to Environment via parameters: – $installPath, $toolsPath, $package, $project
18
Demonstration PowerShell In Packages
19
Web Start-Up Code Simple way to enable start-up of your library in Web Apps WebActivator NuGet library Replacements of the [PreApplicationStartMethod] and [PostApplicationStartMethod] attributes which were included in.NET 4
20
Demonstration Using WebActivator in your packages
21
Extending IDE w/ PowerShell NuGet Packages can add commands to Package Management Console Implement as Standard PowerShell Functions / Modules Register using Init.ps1 NuGet Script
22
Demonstration Extending IDE
23
Package Sources The NuGet Extension supports multiple Package Sources in a hierarchy Problems if One source is down Three ways to add your own: – Local Directories – Read Only Server – Your Own Gallery
24
Working with Multiple Sources Configure sources in Package Manager Settings Choose Source in console Use –Source in Nuget.exe
25
Directory Source Easiest to set up Works over network drives too Add your own packages or pull in public packages
26
Demonstration Own Packages in Directory
27
Hosting Web Based Read Only Next Logical Step, moving closer to the full gallery experience Made possible using a NuGet Package – NuGet.Server It’s a web application, so you can add to it, read more about that here: – http://scou.se/~Gxn http://scou.se/~Gxn
28
Demonstration Hosting Read Only
29
Your Own Gallery NuGet official Gallery is based on Orchard CMS All Open Source – can create your own Gives full fidelity – Create packages and publish to gallery – Browse Gallery – Manage your packages – Extend or integrate with your own requirements Great set of instructions online on the NuGet Documentation site – http://scou.se/~Gxxhttp://scou.se/~Gxx
30
NuGet Gallery Requirements.NET 4 IIS – 2 Hosts, Gallery and Gallery Service SQL Server Express / SQL Server – 2 databases & suitable authentication Mercurial MSBuild in your Path ~1.3GB Disk Space
31
Demonstration Your Own Gallery
32
Summary Explored package consumption Built packages in a variety of ways Seen how PowerShell can be used in the IDE Looked at the options for managing your own NuGet Feed
33
Further Information & Questions Main Site: http://nuget.orghttp://nuget.org Documentation: http://docs.nuget.orghttp://docs.nuget.org Project: http://nuget.codeplex.comhttp://nuget.codeplex.com Mix11 – Scott Hanselman & Phil Haack – NuGet In Depth http://scou.se/~Gyw http://scou.se/~Gyw TechEd North America 11 – Scott Hanselman - NuGet: Microsoft.NET Package Management for the Enterprise http://scou.se/~Gyx http://scou.se/~Gyx NuGet Gallery Project: http://nuggetgallery.codeplex.comhttp://nuggetgallery.codeplex.com Orchard Project: http://www.orchardproject.net/http://www.orchardproject.net/ These slides will be online - http://cwa.me.ukhttp://cwa.me.uk PowerPoint Template Based on http://www.templateswise.com/detail/link-174.htmlhttp://www.templateswise.com/detail/link-174.html
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.