Continuous integration with azure devops for xamarin apps

Azure devops continuous integration allows you to automate build, sign and distribute xamarin apps to the stores. This can also be done entirely in app center. Whichever option you choose, either devops or app center is upto you as they both achieve the similar result.

Build CI for Xamarin apps

Initially, we will create a build pipeline that simply builds both iOS and android projects in one pipeline. For simplicity, we will design the pipeline in debug mode and defer the complexity of signing to a later stage. This is useful as a stage one step as it will ensure any pull request merging to that branch successfully builds before completing it.  Once that is working, we will update the pipeline to release mode which will include signing the apps and creating artifacts.

Pipeline basics

Before we dive into the details of creating a build pipeline, let us discuss a few key aspects involved in devOps CI.

  • Pipeline – A pipeline is composed of one or many stages.
  • Stage– A stage defines a list of tasks. For instance, we can have Android stage and iOS stage.
  • Tasks – performs a specific action such as restoring Nugets packages or  building Xamarin project or  signing Apk etc.
  • Variables – variables store commonly used data that can be shared between stages or pipelines e.g  keystore or p12 passwords, configuration type (debug or release)

See Key concepts for azure pipeline to learn more about pipeline terminology and concepts.

Create build pipeline

There are two ways to create a build pipeline in azure devops, either using yaml or classic editor. The modern way is using yaml as the file can be stored in source control meaning any user who pull downs or clones the source code will also get the build definition as well. However, if you are more of a visual person, you can opt to use the classic editor which guides you in a sortof wizard format manner. In this post, we will use classic editor as its easier to begin with.

Select repository source

Login into azure devops and on the left panel, select pipeline and click on ‘New pipeline’. If you cannot see the button, ensure you have the necessary permissions. Next, select your repository source from the options presented e.g github, azure repos etc. Enter the necessary authorization required to access the repository.

Select the template

Select either Xamarin.Android or Xamarin.ios from the list of predefined templates. We will start with Xamarin.Android which already has a predefined agent phase. Ensure the selected agent is Mac-OS as we want to build both Android and iOS on the same pipeline.  Rename the agent to Agent.Android.

Agent Android stage

To customize the stage for Android, we will modify some of the tasks as discussed below. The main tasks required are:


  • Nuget tool installer – This specifies the nuget to use including the version. We choose version 5.4.0 as this is the latest in time of writing this.


  • MsBuild – This task restores nugets packages with the following settings
    • Project – Browse to Android.csproj location
    • MsBuild arguments – update to /t:Restore to just restore on project level rather than solution level for speed.


  • Xamarin.Android – This builds the android app with the following settings.
    • project – Browse to Android.csproj location
    • output directory – provides output directory for the build e.g $(build.binariesdirectory)/$(BuildConfiguration)
    • Configuration – We set it to $(BuildConfiguration) which is a variable we define with the value debug for now.


Agent iOS stage

On the top pipeline, select add an agent job and rename the agent job giving it an appropriate name such as Agent.iOS. Add the following task by clicking on the plus/add icon next to the agent.


  • Nuget tool installer – This is similar to the android as discussed above. Simply add the task and specify the version desired.
  • Nuget restore – Unlike the android agent job, we user the nuget restore instead of msbuild to restore the nuget package with the following settings:
    • Command – restore
    • path to solution, packages.config or project.json –  Unlike Android, the restore occurs at solution level (**/*.sln) for iOS not project level like android.


  • Xamarin.iOS – Builds the iOS app with the following settings
    • Solution – **/*.sln
    • Configuration – $(BuildConfiguration) which will be similar value to the android i.e debug.
    • Build for iOS Simulator – We select this options at first to just get the build working. Later we will discuss regarding creating the app package which will involve certificates and provisioning profiles to sign the app.


Save and Run the pipeline

The pipeline should now build successfully. For more info see DevOps for mobile video link.


Leave a Reply

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

You are commenting using your 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 )

Connecting to %s