PLEASE NOTE: These aren’t the packages that are on the official NuGet pubished list. There is a MVVM Light NuGet package that will cause error and problems on WP7 projects (by incorrectly installing SL4 assemblies). Please contact the author of that package if you are experiencing problems with that. These ones you can download here (see below) works fine with WP7.
NuGet is an utility that helps you install and reference open source packages into your Visual Studio 2010 project. It helps you to solve the pain points of doing the boring steps of :
- Browse to the home page of the open source project binaries/files.
- Download the latest version
- Right click on properties for the downloaded zip package and select un-block.
- Unzip to a temporary/specific folder
- Add reference to the assemblies on your Visual Studio project.
Imagine how easy it would be if you just could select Add Package –> MVVM Light to your new or existing project. Well, that is exactly what NuGet and this post is all about.
MVVM Light is an excellent MVVM framework toolkit developed by Silverlight MVP Laurent Bugnion.
You will need to download and install the latest NuGet from the CodePlex project site: http://nuget.codeplex.com/ . Go to the Downloads page and click on the NuGet.Tools.vsix link.
Download the MVVM Light NuGet packages
I have created NuGet packages for the following MVVM Light project types, which at this time of writing was version 3.0 SP1:
MVVM Light NuGetPackages
MVVM Light Silverlight 3
MVVM Light Silverlight 4
MVVM Light Windows Phone 7
MVVM Light WPF 3.5 SP1
MVVM Light WPF 4
Add a package to an existing or new project
Download any of the above packages for the targeted project type to a folder of your choice, let’s say c:\NuPackages. Bring the NuPack console up be selecting View->Other Windows->Package Manager Console. In the NuPack console, select the Manage package sources button:
And select the path to where you downloaded the MVVM Light NuPackages and click Add:
Going back to the console, select the new package path in the dropdown, also make sure that you have a project selected:
Type in the command to add your desired MVVM Light package, in this case the Windows Phone 7 package:
Hopefully, everything will work and you have added the MVVM Light dependencies in your project:
Alternatively, you can use the GUI as well, right click on the Reference node in the project and select Add Package Reference.
And select the desired package:
Happy MVVM Light Coding!