NuGet is package management system for .NET and Visual Studio.
It allows people to create simple packages that install files into
your projects, adds references etc. It makes it super simple to get
working components and even scaffolding into your application
without having to search your drive, manually find references,
resolve dependencies etc.
NuGet is a Visual Studio extension that makes it easy to install
and update open source libraries and tools in Visual Studio.
When you use NuGet to install a package, it copies the library
files to your solution and automatically updates your project (add
references, change config files, etc). If you remove a package,
NuGet reverses whatever changes it made so that no clutter is
left.
While NuGet is most popular with the ASP.NET crowd, it's growing
in popularity with Silverlight and WPF developers as well.
Recently, in response to a little prodding Scott Hanselman gave
both me and Tim, Tim Heuer did the work to get the Silverlight
Toolkit on NuGet. That's awesome :)
NuGet is a painless install that doesn't screw up other stuff.
It's a simple Visual Studio extension. Let's try it out.
Step 1: Install NuGet
Go to nuget.org and click on the
giant "Install NuGet" button
NuGet comes as a nice Visual Studio Extension installer (.vsix).
Go ahead and open it and allow it to install into Visual Studio. It
takes about 3 seconds on my SSD :)
Step 2: Find a Package
There are two main modes of operation for NuGet: the dialog
approach and the command line approach. There's a great Getting
Started tutorial on the NuGet codeplex site, so I'll only cover
a subset of it here.
Let's see what's out there for WPF and Silverlight. We'll try
the command-line approach. Under the tools menu, open the Library
Package Manager (NuGet) Console
Once you see the Package Manager Console command prompt at the
bottom of your screen, type "get-package -remote" to list of the
available packages in the official NuGet Repository. In the current
release, it may truncate the list if it's too long (that's being
fixed today). In the mean time, let's try a little
filter/search.
Type "get-package -filter wpf" to see ones with the word WPF in
the ID or description. It returned this for me:
PM> get-package -remote -filter wpf
Id Version Description
-- ------- -----------
AvalonEdit 4.0.0.7070 AvalonEdit is the WPF-based text editor used in SharpDevelop 4.0...
AvalonEdit.Sample 4.0.0.7070 Sample code for AvalonEdit the WPF-based text editor used in Sha...
Catel.Windows 0.9.2 Catel.Windows library which includes the MVVM Framework for WPF ...
Catel.Windows 1.0.0 Catel.Windows library which includes the MVVM Framework for WPF ...
EF4Templates 1.1.0.1 EF4 Templates uses T4toolbox to generate Repositories, Unit of w...
MvvmLight 3.0.0.29166 The MVVM Light Toolkit is a set of components helping people to ...
MVVMT4 1.0.0.0 T4 Templates for generating view models, and views for WPF, Silv...
netfx-System.Windows.Input.DelegateCommand 1.0.0.0 An implementation of WPF ICommand that allows passing delegates/...
Observal 1.0.0.0 Observal is a library that helps you to manage complex, hierarch...
Prism 4.0.0.0 Prism helps you more easily design and build rich, flexible, and...
reactiveui 2.0.0.2 An MVVM library for WPF and Silverlight that is deeply integrate...
reactiveui-xaml 2.0.0.2 WPF and Silverlight specific extensions to ReactiveUI, formerly ...
reactivexaml 1.4.0.0 A MVVM library for WPF and Silverlight that is deeply integrated...
reactivexaml 1.4.1.0 A MVVM library for WPF and Silverlight that is deeply integrated...
SimpleMvvmToolkit.WPF 1.1.0.1 Helper classes, Visual Studio templates, code snippets and sampl...
SimpleMvvmToolkit.WPF 1.1.0.2 Helper classes, Visual Studio templates, code snippets and sampl...
SimpleMvvmToolkit.WPF 1.1.5.0 Helper classes, Visual Studio templates, code snippets and sampl...
I then did the same thing for Silverlight:
PM> get-package -remote -filter silverlight
Id Version Description
-- ------- -----------
BingMapAppSDK 1.0.1011.1716 With the Bing Map App SDK, you can now create your own map apps ...
Catel.Silverlight 1.0.0 Silverlight version of Catel, including all controls and the MVV...
EF4Templates 1.1.0.1 EF4 Templates uses T4toolbox to generate Repositories, Unit of w...
entile-client 0.1.0 The Entile Notification Framework helps you when doing Live Tile...
FlickrNet.Silverlight 3.1.4000 The Flickr.Net API Library is a .Net Library for accessing the F...
FluentAssertions 1.3.0.1 A very extensive set of extension methods for .NET 3.5, 4.0 and ...
FluentValidation 1.3.0.0 A validation library for .NET, Silverlight and WP7 that uses a f...
FluentValidation 2.0.0.0 A validation library for .NET, Silverlight and WP7 that uses a f...
jLight 0.1 Interop between Silverlight and the javascript based on jQuery. ...
Moq 4.0.10827 The simplest mocking library for .NET 3.5/4.0 and Silverlight wi...
MvvmLight 3.0.0.29166 The MVVM Light Toolkit is a set of components helping people to ...
MVVMT4 1.0.0.0 T4 Templates for generating view models, and views for WPF, Silv...
Prism 4.0.0.0 Prism helps you more easily design and build rich, flexible, and...
protobuf-net 1.0.0.280 protocol buffers is the name of the binary serialization format ...
qdfeed 1.0.2 A lightweight .NET library designed to give developers an agnost...
ReactiveOAuth 0.2.0.0 Reactive Extensions base OAuth library for .NET Framework 4 Clie...
reactiveui 2.0.0.2 An MVVM library for WPF and Silverlight that is deeply integrate...
reactiveui-xaml 2.0.0.2 WPF and Silverlight specific extensions to ReactiveUI, formerly ...
reactivexaml 1.4.0.0 A MVVM library for WPF and Silverlight that is deeply integrated...
reactivexaml 1.4.1.0 A MVVM library for WPF and Silverlight that is deeply integrated...
SilverlightToolkit-All 4.2010.4 The complete Microsoft Silverlight Toolkit. Details at http://s...
SilverlightToolkit-Core 4.2010.4 The core components Microsoft Silverlight Toolkit. Details at h...
SilverlightToolkit-Data 4.2010.4 Data components of the Microsoft Silverlight Toolkit. Details a...
SilverlightToolkit-DataViz 4.2010.4 Data visualization components of the Microsoft Silverlight Toolk...
SilverlightToolkit-Input 4.2010.4 Input components of the Microsoft Silverlight Toolkit. Details ...
SilverlightToolkit-Layout 4.2010.4 Layout components of the Microsoft Silverlight Toolkit. Details...
SilverlightToolkit-Theming 4.2010.4 Theming components of the Microsoft Silverlight Toolkit. Detail...
SilverlightToolkitWP 4.2010.11 The Microsoft Silverlight for Windows Phone Toolkit. Details at...
SimpleMvvmToolkit.Silverlight 1.1.0.1 Helper classes, Visual Studio templates, code snippets and sampl...
SimpleMvvmToolkit.Silverlight 1.1.0.2 Helper classes, Visual Studio templates, code snippets and sampl...
SimpleMvvmToolkit.Silverlight 1.1.5.0 Helper classes, Visual Studio templates, code snippets and sampl...
StatLight 1.2.3919 StatLight: Tool for executing Silverlight test xap packages loca...
StatLight 1.3.3981 StatLight: Tool for executing Silverlight test xap packages loca...
There's a fair amount of stuff available for Silverlight as
well. Very cool, indeed.
Step 3: Install a Package
There are a few WPF and Silverlight packages of interest there.
Prism, ReactiveUI, Rx Extensions, the Silverlight Toolkit,
SimpleMvvmToolkit, Windows 7 API Code Pack, and more. I'm going to
install Prism, since it's interesting and has some dependencies
that will need to be resolved.
First, if you haven't already, create a new WPF Windows
app. Most NuGet packages need a project to install
into.
Then, at the command prompt, type "install-package prism"
PM> install-package prism
'CommonServiceLocator (≥ 1.0)' not installed. Attempting to retrieve dependency from source...
Done
Successfully installed 'CommonServiceLocator 1.0'
You are downloading Prism from Microsoft patterns & practices, the license agreement to which is available at http://compositewpf.codeplex.com/license. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Prism 4.0.0.0'
Successfully added 'CommonServiceLocator 1.0' to WpfApplication2
Successfully added 'Prism 4.0.0.0' to WpfApplication2
The process took maybe 4 seconds at most (NuGet is really fast)
and updated the references in my project, automatically including
the correct libraries and, as you saw, installing any required
dependencies. Due to the nature of NuGet packages at the moment,
you typically don't get any templates. I hope to see that change in
the future.
Step 4: Profit
If you're a tools or toolkit author, put your stuff in
NuGet today. This is a great package management system
(whether you use the command line or dialog approach) for Visual
Studio. It saves you from having to deal with all the usual hunting
and manual dependency referencing in your projects.
There's a lot of talk inside Microsoft about getting different
projects and packages out on NuGet. Expect to see more soon.
If you're a developer using NuGet, you'll find it often quicker
than using even the new add reference dialog. Definitely go try it
out.