Xamarin – Package and Component Restore

We usually don’t keep packages and components dlls in the code repository.

Sadly, the Xamarin Studio IDE is not very good at restoring packages and components. More often than not, when someone clones a project and opens it for the first time, the IDE will not restore everything.

At this point, the common remedy is to open and close the studio several times, delete the project and re-clone it and other voodoo stuff.

Luckily for us, there are command line tools that you can use to explicitly restore dependencies. They are NuGet.exe and xamarin-component.exe.

I think the original motivation for these tools is CI (and we are using them for CI) but they are also quite useful on developers’ machines.

Note that the NuGet.exe utility is a special mono flavor. Apparently you can’t use the vanilla NuGet utility.

Instructions for use

Download

Download NuGet and the xamarin component tool. I usually add the files to each repository so they are always available to developers and to the build server.

Login to Component Store

To setup the xamarin component tool, you need to login with it to the component store. You do this only once and it will store your credentials info in your user folder so you don’t have to repeat it again


$ mono xamarin-component.exe login me@my.company
Password:
INFO (login): Computed cookie jar path: /Users/doron/.xamarin-credentials
INFO (login): Credentials successfully stored.

Restore Components

To restore components, you run xamarin-component.exe with the restore option and give it the path to your solution file.


$ mono xamarin-component.exe restore MyApp.sln

Restore Packages

To restore packages, you run NuGet.exe with the restore option and give it the path to your solution file.


$ mono NuGet.exe restore MyApp.sln

Summary

We demonstrated the use of NuGet.exe and xamarin-component.exe, 2 command line tools that enable you to manually restore packages and components.

These tools can be used either on a build server or by developers to overcome Xamarin Studio’s problems with restoring dependencies.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s