Building Xamarin projects


Visual Studio 2015 build image (which is default image for OSS plans) has Xamarin Platform pre-installed and allows building Android and iOS libraries.

Building .ipa application packages requires Mac computer and is not currently supported.

Restoring Xamarin components

To restore Xamarin components on build worker you use xamarin-component.exe tool. The tool is available at the following location:

Rename the downloaded file to and unzip to extract the tool.

The main challenge of using this tool on a build server is that to restore components it requires authentication with your Xamarin credentials, however login action prompts for password interactively thus blocking the build.

Fortunately, it’s possible to copy cached credentials (“cookie jar”) from your local development machine to a build worker and it will work.

On your local development machine open command prompt at the location with xamarin-component.exe tool and run the following command to authenticate (from Windows):

xamarin-component.exe login <>

Or, if you’re running on a Mac:

mono xamarin-component.exe login <>

Cached credentials are stored in C:\Users\<user>\.xamarin-credentials file (or on a Mac: /Users/<user>/.xamarin-credentials). Open that file and copy the number after, to a clipboard.

Open AppVeyor project settings and add a new environment variable called XAMARIN_COOKIE with the value from clipboard.

To download and configure packaging restore tool add these PowerShell commands to “Install” section of your build (install section in appveyor.yml):

$zipPath = "$($env:APPVEYOR_BUILD_FOLDER)\"
(New-Object Net.WebClient).DownloadFile('', $zipPath)
7z x $zipPath | Out-Null
Set-Content -path "$env:USERPROFILE\.xamarin-credentials" -value ",$env:XAMARIN_COOKIE"

To restore components used in the solution add this command to “Before build” section (before_build section in appveyoryml):

xamarin-component.exe restore <path\to-you-solution.sln>
Did you know that you can edit this page on GitHub and send us a Pull Request?