12 steps to get started with Mobile DevOps

I prepared my mobile DevOps demo for our roadshow yesterday. I created an end to end scenario with Xamarin, Visual Studio Team Services (VSTS), the Xamarin test cloud and HockeyApp. I was pretty impressed that it only took me a few hours to get everything running. But there were some pitfalls – so here is a step by step guide to get you up and running in a few hours.

1. Install Xamarin

If you haven’t installed Xamarin yet you can do it with the Visual Studio installer. Open Programs and Features, select Visual Studio Enterprise 2015, click change and select modify.

Under Cross Platform Mobile Development select C#/.Net (Xamarin v4.1.0). This will automatically activate some other features like Android SDK.

Install Xamarin 4.1

2. Create your Xamarin project in Visual Studio

Create a new solution in your VSTS repository of the type Blank App (Native Portable).

Create Xamarin Project

This will create four projects: a portable library that is referenced in all other projects, one project for iOS, one project for android and one project for windows phone.

If you hit F5 an Android emulator should come up and display the sample code (an app with a button that counts the clicks on it).

Android emulator

3. Add UITests

To use the Xamarin Test Cloud you have to add UI tests to your project. Add a new project of the type “UI Test App”.


In the class “AppInitializer” add the relative path to the apk package.


Now add a new test that clicks the button and verifies that the text is updated correctly. Note that I’ve added a screenshot to the test after clicking the button.

public void ClickButton()
    app.Tap(x => x.Button("myButton"));

    app.Screenshot("Tab Button");

    var result = app.Query(x => x.Button("myButton").Text("1 clicks!"));

    Assert.IsTrue(result.Any(), "The expected text was not found.");

4. Create keystore file

To use the HockeyApp for distribution it is required to sign the package in the build. To sign the package we have to add a keystore to the project. Open a command prompt and navigate to your solution folder. Expand the %PATH% to include your version of the JRE. Start keytool with the following arguments:

$ set path=%path%;C:\Program Files (x86)\Java\jre1.8.0_45\bin
$ keytool -genkey -v -keystore my-release-key.keystore -sigalg SHA1withDSA -keyalg DSA -keysize 1024

Enter the passwords and data that is needed for the certificate. After the keystore was execute the following command:

$ keytool -keystore .\my-release-key.keystore -list -v

Note the alias for later user.

Add the keystore to your repository and commit and push all your changes to your Visual Studio Team Services project.

5. Create your team build

If you don’t have a Xamarin account yet, then sign up for it now. You will need the email and password during the build creation.

Open your project in VSTS and create a new build from the Xamarin.Android template.

Create Xamarin.Android build

Go to the variables tab and add some variables:

  • XAccount: the Xamarin Account email
  • XPass: the Xamarin Account password
  • KeyPass: password key for key (see step 4)
  • optional: key store password if different (see step 4)
  • KeyAlias: alias for key (see step 4)

Add variables to the build

For the “Activate Xamarin license” and “Deactivate Xamarin license” tasks set the email and password to $(XAccount) and $(XPassword).

Add a “Copy file task” before the signing task and copy the keystore to the binaries directory.

Copy file task

Enable Jarsigning and Zipalign in the “Signing and aligning APK file(s)” task. Note that the path to the keystore contains the project name – depending on the copy file task and your project structure! I’ve used the same password for the keystore and the key. If you have different passwords you have to use the corresponding variable here.

Enable Jarsigning and Zipalign

Log in to https://testcloud.xamarin.com and get the API key for your team.

Get Xamarin Test Cloud API Key

Create a new test run.

New test run

Select the devices that you want to run the tests on and follow the wizard to the last page. You only need the devices string. Copy the string and cancel the wizard.

Get devices string

Go back to your build and enter the data gathered (API key, device string) in the Xamarin Test Cloud task.

Enter values in xamarin test cloud task

The see the test output in the build results you have to add a publish test results task to the build.


Publish the results directory ($(build.binariesdirectory)\$(build.configuration)) to the drop artifact.

Publish artifacts

Run the build and verify that everything works as expected.

6. Link HockeyApp to you VSTS project

Login to https://rink.hockeyapp.net and create a API token with full access. You find this under “Account Settings” / “API Tokens”.

Get API Token in HockeyApp

Go to the settings of your VSTS team project and create a new service endpoint with the API key you just created.

Set HockeyApp Service in VSTS

7. Create a release definition

Create an empty release definition. Enable continuous deployment and keep the rest of the default values in wizard.

Create a release definition

Link your build to the release definition.

Link build output to the release

Add an environment and add a HockeyApp task. Select the service endpoint from step 6 and browse to your .apk file from the build output. Select if you want to notify users or make the release mandatory.

Add environment and HockeyApp task

Deploy the latest build with the release definition to create the app in HockeyApp.

8. Install Hockey App on your Android phone

Allow installation of apps on your Android phone. You can enable this in Settings –> Security –> Allow unknown sources. Now install the app. The app is not in the store – you have to install it from HockeyApp web site.

Launch the app and sign in with your credentials. You should now see your app. Install and run it on your phone.

9. Enable Crash and Update Reporting in your Project

To enable crash reporting and update notification we have to add some code to the project. Before we do this we have to log in to the HockeyApp web site and get the app id that was automatically generated during your release.

Get HockeyApp App Id

Now open your solution and add the nuget HockeySDK.Xamarin to your Android project. Register the app with the CrashManager and UpdateManager.

[Activity (Label = "DemoApp1.Droid", MainLauncher = true, Icon = "@drawable/Icon")]
public class MainActivity : Activity
	int count = 1;

	protected override void OnCreate (Bundle bundle)
		base.OnCreate (bundle);

		// ...

        CrashManager.Register(this, "<app id>");
        UpdateManager.Register(this, "<app id>");

    protected override void OnPause()


    protected override void OnDestroy()


10. Enable VSTS Integration in HockeyApp

To receive feedback and crash reports in VSTS we have to enable the integration in HockeyApp. You enable this under Manage App / Visual Studio Team Services.

Enbale VSTS integration in HockeyApp

11. Enable Feedback

To allow the user to send feedback we have to add a new button. Add a feedback button in Main.axml. Add the caption to Strings.xml.

Add feedback button

Register the app with the FeedbackManager and add a delegate to the click event of the button that calls the ShowFeedbackActivity method of the FeedbackManager.

Button feedbackButton = FindViewById<Button>(Resource.Id.myFeedbackButton);

feedbackButton.Click += delegate

FeedbackManager.Register(this, "<app id>");

12. End to end test

Everything should be ready at this point and you can start an end 2 end test. Add a “bug” to MainActivity.cs that crashes the app if you click the button 5 times.

button.Click += delegate

    if (count == 5)
        throw new InvalidOperationException("This is a bug that crashes the application.");

    button.Text = string.Format("{0} clicks!", count++);

Also update the version number to see if the update notification works.

Update app version

If your build is set to continuous integration it is automatically triggered. The build runs the UI tests in the cloud and displays the test result in your build overview.

Build with xamarin test results

Go to https://testcloud.xamarin.com and open your app. You can see more details here including the screenshots of your app that you added to the tests.

Xamarin Test Cloud Result Overview

Xamarin Test Cloud Result Screenshots

If your release was set to continuous deployment your app was automatically deployed to your first environment using the hockey app. Launch the app on your phone. It should automatically detect the update. Install the update.

Update app

Now crash the app by click the first button 5 times. If you start the app again you can send the crash report to hockey app.

Send crash report

The crash report is automatically added as a bug to your team project.

Bug for crash in VSTS

Now push the “Send Feedback button” and fill out all the required fields in the form.


The feedback will be added to VSTS as a task.

Feedback task in VSTS


I was really impressed how easy it was to get the complete mobile DevOps lifecycle implemented. I hope this gives you a good start up if you want to start to play around with mobile DevOps and continuous deployment of cross platform apps. If you have problems with some steps just leave me a comment and I will try to help.

Get a list of all Releases in TFS or Visual Studio Team Services

I have a customer that is transitioning from the old version of Release Management to the new one. The question today was, how he can get an overview of all releases in all projects that are going on.

I don’t think this is possible yet with the UI – so I cam up with a small script that uses the REST API to get the releases. The script gets all projects for a project collection and retrieves all the releases for each project. It then sorts the output and displays it as a table.

You could also dump it to a json and display it in a html site if you want to display the releases in a dashboard.

Param (
    [Parameter(Mandatory=$true, Position=0)]

$projectsResult = Invoke-RestMethod "$ProjectCollection/_apis/projects?api-version=1.0" -Method Get -UseDefaultCredentials

$releases = @()

$projectsResult.value | % {

    $project = $_.name

    $url = "$ProjectCollection/$project/_apis/release/releases?api-version=2.2-preview.1"

    $result = Invoke-RestMethod $url -Method Get -UseDefaultCredentials

    if ($result.count -gt 0){
        $result.value | % {
            $releases += [pscustomobject]@{ 
                Project = $project 
                Name = $_.Name 
                Status = $_.status
                CreatedOn = [datetime]$_.createdOn
                ModifiedOn = [datetime]$_.modifiedOn 

$releases | Sort-Object -Property ModifiedOn -Descending | Format-Table -AutoSize

If you want to use the same technique in VSTS you have to create a personal access token first. The good thing with personal access tokens is, that you can restrict access to certain features (like Release (read)) and revoke access later.

To create the token click under you Name on My Security and create the token with the correct permissions (see image).

Create personal access token in VSTS VSO

Copy the personal access token and use it as a parameter to the script.

Copy personal access token

Here is the script to get the releases in VSTS.

Param (
    [Parameter(Mandatory=$true, Position=0)]

    [Parameter(Mandatory=$true, Position=1)]

$passkey = ":$($Accesstoken)"
$encodedKey = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($passkey))
$token = "Basic $encodedKey"

$projectsResult = Invoke-RestMethod "https://$Account.visualstudio.com/_apis/projects?api-version=1.0" -Method Get  -Headers @{ Authorization = $token }

$releases = @()

$projectsResult.value | % {

    $project = $_.name

    $url = "https://$Account.vsrm.visualstudio.com/$project/_apis/release/releases?api-version=3.0-preview.2"

    $result = Invoke-RestMethod $url -Method Get -Headers @{ Authorization = $token }

    if ($result.count -gt 0){

        $result.value | % {
            $releases += [pscustomobject]@{ 
                Project = $project 
                Name = $_.Name 
                Status = $_.status
                CreatedOn = [datetime]$_.createdOn
                ModifiedOn = [datetime]$_.modifiedOn 

$releases | Sort-Object -Property ModifiedOn -Descending | Format-Table -AutoSize

Note that the URL points to vsrm.visualstudio.com and that the api version is also different.

If one of the scripts does not work then check the current state of the api version in the REST documentation.

Where is my git ignore file in Visual Studio?

If you work a lot with github, then you are used to add a .gitignore file when you initialize your repository.


If you create a project in TFS or Visual Studio Team Services this is not the case. You have to add your .gitignore file using the team project settings. Under settings navigate to repository settings.

Team Explorer_Settings

Team Explorer_Repository Settings

Look for the “Ignore File” and click “add”. Edit the file if you need to do any modifications.

Add and edit gitignore file

Now commit the .ignorefile and push your changes to the server.

The git integration in Visual Studio and TFS is pretty good – but a lot of features are well hidden. And some things are not that intuitive as they should be.

PowerShell DSC for SharePoint

I stopped the work on my DSC modules for SharePoint (xSharePointAdministration) some time ago because the PowerShell team was working on the xSharePoint module. The module has now reached Version 1.0 and was renamed to SharePointDSC.

The module is already pretty mayor and can be used to deploy SharePoint 2013 and SharePoint 2016. It supports PowerShell 4.0 and 5.0. I already started using it in some customer projects.

It’s not yet perfect – but what the PowerShell team does is really “Open Development” and not just “Open source”. I contributed the xSPFarmSolution resource, the version parameter for the xFeature resource and the xSPWeb resource and it was really a great experience. Many thanks to Brian Farnhill and Travis Plunk. So start using it for future deployments. If you find any bug or need additional resources you get a great support from the community.

If you are new to PowerShell DSC you can watch the the video from Brian. It gives you a great introduction in DSC in general, the SharePointDSC module (formally xSharePoint) and how you use it together in Azure.

Update: The module was released as Version 1.0 on 6/7/2016. See this post for more Details.

Band2 cannot be paired with windows phone

The problem

I had my Microsoft Band2 repaired because the battery wouldn’t charge any more. When the band came back I was not able to pair it with my Windows Phone. The band worked fine – it was just the app that did not recognize any band. I tried reinstalling the app – but nothing worked.

The solution

A chat with the support helped me. The trick is to change the language of your phone – reboot – and try the pairing again. After changing the language my band showed up and I was able to pair it. After successful pairing you can switch your language back to the original value. A simple solution – but I would never have figured that out on my one.

Use SonarLint to work on your technical debt in Visual Studio

SonarQube is a really great solution to monitor and track your technical debt over time. But wouldn’t it be great if the developer could already see in Visual Studio the impact that his commit will have to the sonar dashboard? If you use Visual Studio 2015 and the C# Plugin for SonarQube you can do this with the extension SonarLint.

The extension depends on the latest version of the C# Plugin – so make sure that you have the latest version (5.2) installed.

In Visual Studio install the extension in the “Extensions and Updated” dialog.

Install SonarLint Extension

This adds a new Tile ‘SonarQube’ to your Team Explorer.

SonarLint Menu in Team Explorer

You can use this tile to connect to your SonarQube instance.

Configure SonarLint Connection

Once connected you can bind your current solution to a project from the SonarQube instance.

Bind Solution ti Sonar Project

Now all the Errors and Warnings from your SonarQube project will show up in the error window in Visual Studio.

Sonar Error in Visual Studio

SonarLint uses Roslyn to perform the analysis so that you can use all tooling that you get from the roslyn compiler. You can suppress the message from within the code if you like.

Roslyn and Suppresions

You also can leverage the new features from the static code analysis in Visual Studio like only showing messages for the changed documents.

Filter Errors

So that’s it. A really small extension with a very big impact. I’ve always been a big fan the FxCopy and the static code analysis – But I’ve always missed a central point to manage the rules and to monitor the output over time. SonarQube is perfect for that – but without a Visual Studio integration it was not a complete solution. SonarLint closes that gap and integrates the Visual Studio toolchain perfectly with SonarQube.