Monday, January 27, 2020

Implement CI/CD for Xamarin Mobile Application using Azure DevOps

What is Azure DevOps?


Azure DevOps is a Software as a service (SaaS) platform from Microsoft that provides an end-to-end DevOps toolchain for developing and deploying software.  It also integrates with most leading tools on the market and is a great option for orchestrating a DevOps toolchain.  At DevOpsGroup, we have lots of customers who have found Azure DevOps fits their needs irrespective of their language, platform or cloud.


What can Azure DevOps do?

Azure DevOps comprises a range of services covering the full development life-cycle.  At the time of writing these are:



  • Azure Boards: agile planning, work item tracking, visualization, and reporting tool.
  • Azure Pipelines: a language, platform and cloud-agnostic CI/CD platform with support for containers or Kubernetes.
  • Azure Repos: provides cloud-hosted private git repositories.
  • Azure Artifacts: provides integrated package management with support for Maven, npm, Python and NuGet package feeds from public or private sources.
  • Azure Test Plans: provides an integrated planned and exploratory testing solution.



Azure DevOps can also be used to orchestrate third-party tools.

View of Azure DevOps:



Repository for Xamarin-app in Azure DevOps Repos

You can you Azure DevOps as for your version control system.


Create a Pipeline for Xamarin.Android Application

This will cover the basics of the Xamarin build pipeline.

In-order to create build pipeline for your xamarin app you can follow the steps below.

To create a build pipeline for Xamarin.Android application, go to Pipelines in left side bar and inside the Builds click the New pipeline button.


It will direct you to below page


Here you can select which way you need to create a pipeline. Mainly it will go to YAML template format. But if you are not much familiar with YAML format my recommendation is to go with the classic editor to create a pipeline. It will easy to manage every config and will take less time to complete.

In this tutorial, I'm using the classic editor to create this pipeline. You can follow the steps as below.

Select your repository:


You can select whichever source you have in the above list (GitHub, Bitbucket... etc). You can select the Team project, Repository, and branch for the builds. Once you provide the repository information click on Continue.

In the next window, you can select which template you need to use for the build pipeline.



In the search box enter xamarin and select Xamarin.Android. Then click next.


It will create a template for Xamarin.Android with all necessary tasks as below. 



You can add or remove tasks from your job as your preference. Then provide the relevant configurations for each task as follows:

  • Agent job configurations:
Select the agent specification you want to run your android build. You can configure the execution plan as well.
  • NuGet tool installer task configurations:
Specify the version of the NuGet tool.

  • NuGet restore task configurations:
Configure the solution file path for NuGet packages restore.


  • Xamarin.Android task configurations:
Select below configurations:
  •  Android project file path (android.csproj)
  • Output directory
  • Configuration - Build configuration create an environment variable "BuildConfiguration" and assign the relevant value. (Debug, Release...etc)
  • MSBuild version
  • MSBuild architecture
  • Additional arguments for MSBuild (If any)
  • Select JDK for the build

  • App signing task configurations:
You need to provide .apk file path to sign the built apk file. Provide Keystore file, Keystore password, alias and key password.


  • Publish build artifacts task configurations:
Using this you can publish your build artifacts into artifactory.

Finally, Click Save & queue. 
You will all logs related to each and every task in this build job.



Create a Pipeline for Xamarin.iOS Application

Create a build pipeline for Xamarin.iOS application you can go to Pipelines and click the New and select New build pipeline.



Click on classic editor


Select your repository details and click Continue


Select the template for the pipeline. 

In the search box enter xamarin and select Xamarin.iOS and click on Apply.


It will create a template for Xamarin.iOS as follows


You can provide relevant configurations for each task.

For agent job please select macOS as an agent for iOS build job.


Specify the xamarin iOS project file (iOS.csproj) for the Solution parameter. Add the BuildConfiguration (as an environment variable) for the Configuration parameter.

Finally click Save & queue.

You can see the log for every task in build job.