Xamarin Projects – Configuration Tips

Use .gitignore

By default, you want to ignore anything that is automatically generated or downloaded. This includes compiler output (e.g. obj files), packages and components, user settings, etc.

Note that if you’re using Xamarin Visual Studio Extension, you probably want to base your .gitignore on a visual studio template.

This is what I use for my projects:


Use command line tools to restore components and packages

Since we don’t keep assemblies in the repository, we need a way to restore them.

There are 2 issues here:

  1. Xamarin Studio is not so good in restoring dependencies. Most of the time it fails to restore all dependencies.
  2. If you’re using a CI server you want to be able to restore dependencies from command line.

See my previous post about command line tools for restoring dependencies.

I put both tools in the repository’s root folder so they are always available.


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 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
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


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.