A new version of Xamarin Studio was released as part of Xamarin 3, and one of its new features and improvements is first class support for NuGet which is now built in and fully integrated.

nugetlogo

NuGet is a package management system for .NET that simplifies the process of using third party libraries in your application. It provides access to over 20,000 third party libraries which are available from the main NuGet package gallery.

Microsoft are also embracing NuGet. Microsoft use NuGet as one of the primary ways to release libraries and have their own curated NuGet package feed.

Xamarin is also using NuGet to distribute libraries. Xamarin.Forms, the new library which allows you to build native UIs for iOS, Android and Windows Phone from a shared C# codebase, is available to download from NuGet and install into your application.

Thousands of libraries are available from NuGet, many of these are compatible with Xamarin’s frameworks, that can be used in your iOS, Android, Mac and Windows applications. There are also an increasing number of NuGet packages that contain Portable Class Libraries (PCLs), that are compatible across a range of desktop and mobile frameworks. All of these libraries are now easily available to you from within Xamarin Studio.

Xamarin Studio NuGet Features

  • Search across thousands of third party libraries available as NuGet packages.
  • Quickly add NuGet packages to your application and start using them.
  • Easily update a single package or all packages to their latest versions.
  • Automatically restore packages on opening your solution.
  • Project templates can install NuGet packages when a new project is created.
  • Consume packages from other third party NuGet package sources.
  • Search for NuGet packages from the universal search.
  • Deep integration with Xamarin Studio – integrates with the Solution window, the status bar and the universal search.

Now let us take a look at some of these Xamarin Studio features starting with adding a NuGet package to a project.

Adding a NuGet Package

With your project open in Xamarin Studio, from the Solution window, right click the project and select AddAdd Packages.

Add Packages menu option

This will open the Add Packages dialog showing you a list of NuGet packages available from the main NuGet gallery.

Add Packages Dialog

From this dialog you can search for NuGet packages and quickly add them to your project. Once you have found a package you can install it by simply selecting it and double clicking or by clicking the Add Package button. The dialog will then close and Xamarin Studio will install the NuGet package in the background. As the install proceeds Xamarin Studio’s status bar will be updated with progress messages.

StatusBarAddingXamarinForms

StatusBarXamarinFormsAdded

Detailed information on what happened during the install can be seen in the Package Console window.

Xamarin Studio Package Console Window

The Solution window will display a Packages folder which contains all the packages installed in the project.

Package Context Menu in Solution Window

From the Packages folder you can easily update a package to the latest version, or remove it from the project, by right clicking and selecting the appropriate menu item.

Assembly references added to the project by the NuGet package are displayed inside the From Packages folder in the Solution window.

Xamarin Studio From Packages Folder

Restoring NuGet packages

Xamarin Studio will automatically restore any NuGet packages that are missing when a solution is opened. This means you do not need to add NuGet packages to your source control system. Only the packages.config file for each project needs to be added to your source control system. When another developer opens the solution for the first time all the missing NuGet packages will automatically be downloaded and restored by Xamarin Studio.

Xamarin Forms Sample Packages Restored

In the screenshot above the Xamarin.Forms button source code sample, which uses NuGet packages, was opened in Xamarin Studio and the NuGet packages were automatically restored.

Project Templates with NuGet Packages

Project templates now have support for NuGet packages so Xamarin Studio can install NuGet packages when a new project is created. The project templates for Xamarin.Forms takes advantage of this feature and will install NuGet packages when a new Xamarin.Forms project is created.

Learn More

This is the end of our introduction to the NuGet support in Xamarin Studio. If you would like to learn more about Xamarin Studio then here are some more resources.