Updating Component References to NuGet
- PDF for offline use
- Related Links:
Let us know how you feel about this
last updated: 2017-11
Replace your Component references with NuGet packages to future-proof your apps.
This guide explains how to update existing Xamarin solutions to change Component references to NuGet packages.
Most components fall into one of the above categories. If you are using a component that does not appear to have an equivalent NuGet package, read the components without a NuGet migration path section below.
Components that contain NuGet packages
Many components already contain NuGet packages, and the migration path is simply to delete the component reference.
You can determine whether the component already includes a NuGet package by double-clicking on the component in the solution:
The Packages tab will list any NuGet packages included in the component:
Note that the Assemblies tab will be empty:
Updating the Solution
To update your solution, delete the Component entry from the solution:
The NuGet package will remain listed in the Packages node and your app will compile and run as usual. In future, updates to this package will be performed via the Nuget update feature:
Components with NuGet replacements
If the component info page Assemblies tab contains entries as shown below, you will need to find the equivalent NuGet package manually.
Note that the Packages tab will probably be empty:
It may contain NuGet dependencies, but these can be ignored.
To confirm a replacement NuGet package exists, search on NuGet.org, using the component name, or alternatively by author.
As an example, you can find the popular sqlite-net-pcl package by searching for:
Updating the Solution
Once you have confirmed the component is available in NuGet, follow these steps:
Delete the component
Right click on the component in the solution and choose Remove:
This will delete the component and any references. This will break your build, until you add the equivalent NuGet package to replace it.
Add the NuGet package
- Right-click on the Packages node and choose Add Packages....
Search for the NuGet replacement by name or author:
Press Add Package.
The NuGet package will be added to your project, along with any dependencies. This should fix the build. If the build continues to fail, investigate each error to see if there were API differences between the component and the NuGet package.
Components without a NuGet migration path
Don't be concerned if you don't immediately find a replacement for components used in your application. Existing components will continue to work in Visual Studio 15.5, and the Components node will appear in your solution as usual.
Future Visual Studio releases, however, will not restore or update components. This means if you open the solution on a new computer, the component will not be downloaded and installed; and the author will not be able to provide you with updates. You should plan to:
- Extract the assemblies from the component and reference them directly in your project.
- Contact the component author and ask about plans to migrate to NuGet.
- Investigate alternative NuGet packages, or seek the source code if the component is open-source.
Many component vendors are still working on migrating to NuGet, and others (including commercially available products) may be investigating alternative delivery options.