Visual Studio App Center : Building a CI/CD pipeline for mobile app deployment

Nomadic Harish
8 min readOct 19, 2020

--

App Center

Microsoft’s Visual Studio App Center is an incredible resource for mobile application developers which helps to quickly create high-quality apps for Android, iOS, macOS, and Windows . In the App center, you can automate your build in cloud directly from the repository, test your app on 1000+ physical devices which is hosted on cloud and distribution to beta testers or live production environment. It also helps to continuously monitor real-time performance and crash reports of your app; All in one place.

It may seem to be hard to get started, but once you get started, it turns out to be pretty easy!

The App Center provides a one-stop shop for managing the mobile-optimized development lifecycle in your mobile apps, covering part of the test as well as the build, distribute, and monitor.

  • Build : App Center consists of tools that can take your code and build it either on demand or when you push to source code control. The App Center can connect to a source code repository. For each branch in your repo, you can create a build to compile your solution or an individual project using any available build configuration, either on demand or whenever the code is updated in the repo. You can sign your build using an Android keystore or iOS provisioning profile and even launch it on a real device, using Test Cloud as a sanity check to ensure that your app runs and doesn’t crash on startup.
  • Distribute : From the App Center, you can distribute your builds to the beta testers. The beta testers will receive an email with a link to download your app, so that they can test it, and they can even receive notifications in their app when ever an update is available. You will also be able to distribute to the Google Play and Apple App Stores.
  • Test : The App Center integrates with Test Cloud, which allows you to take the UI tests you wrote and run them on real devices in the cloud. App Center can be used to configure, start, and display the results of these test runs.
  • Crashes: Most of the apps will crash at some point. Hence, the App Center has an SDK which can be added to your apps to track crashes. If your app crashes, the App Center SDK will track this, and the next time your app is run and is online, it will upload the crash details, including the stack trace, to the App Center.
  • Analytics : It is always good to know how your users are using your app, so that you can track pain points and see what features are popular or are not being used. It helps you to know which areas to work on. It also helps to see user demographics —for example, if your app is in English, but is popular in Italy, you might want to offer it in Italian. The App Center SDK can help to track this kind of information.

Getting Started with VS App Center

To begin with, you need an App Center account. Go to http://appcenter.ms where you will find the welcome screen. Click on Get Started and create an account.

Now you need to create a local app. Here we are creating a Xamarin.Forms app “AppCenterBlogDemo” in Visual Studio 2019. Feel free to create whatever kind of app that you like, Build it and make sure it runs.

Creating your app in the App Center

Lets add your project into the App Center. Go back to the App Center and click on Add New App from the welcome screen. A dialog slides out, where you can name your new app. You can choose the release type, OS type and the platform in which your project is developed on.

This will create the app and show a Getting Started page with details on how to set up the App Center SDK for crash reporting and analytics (we will look at that during the upcoming part).

The App Center is built on the concept of apps, with each app being a single, releasable app for a single platform. Although you may think of cross platform single app available on iOS and Android, from the perspective of the App Center, they are actually two apps, one Android and one iOS.

Connect to Repository

The App Center apps are based on the codes for a mobile app from a source control repository. So, before you can set up a build, you need to put the source code for your app into a repository which the App Center can access. The App Center supports multiple source control providers. Once you login to the repo, it will show the projects in the repo and you can select the corresponding project to get connected.

Once a repository is connected from any of these providers,you can see all the branches of the project with commit details. A branch from the repository is to be selected as the source for the build process.

Build Configuration

Now in each app, you can see a list of branches in your repository. By clicking on the branch, you will be allowed to add a build configuration.

A Build configuration depends on the technology and OS platform combination. For Android applications, required information would be Android SDK version number, Keystore details for signing etc. Whereas, for iOS applications, you will need to specify the details like iOS SDK version, Xcode version, provisioning profile, signing certificate etc.

This configuration is divided into four sections:

  1. Build App : In this section you can configure how your app should be built. Lets us go into the details of each options:

Project: The first option is the project to build. Your solution could contain multiple Android apps, so here you can select the one to build.

Configuration : From here you can set the build configuration you want to compile with: either Debug or Release.

SDK Version: Here you can select which version of Xamarin.Android / Xamarin.ios to use when compiling your app. Select the latest stable SDK version.

Build Frequency: The build frequency can be set to either on every push to this branch, or manually, on demand. Leave this set to build this branch on every push, this way every time you push one or more commits to your repository, the app will be rebuilt.

Automatically increment version code: You can also mention how the Build Number needs to be updated in this step. You can either choose “Build ID” which would be a plain whole number which gets incremented in each build (value will be 1 for first build) or the current Time Stamp. Both of these options would result in new builds being created with higher build numbers than before. The build number is not to be confused with application version number which appears in App Store/Play Store.

2. Sign Builds: App Center can sign your builds using your Android keystore. Turn on Sign Builds, upload your keystore from the very safe place where you keep it, enter the alias you used when creating it in the KEY_ALIAS, and then enter your keystore password into both the KEYSTORE_PASSWORD and KEY_PASSWORD fields (when you set up a keystore using Xamarin, it uses the same password for the keystore as for the signing key inside it).

If you are creating the app in App center for iOS app, then the App center can sign your iOS builds using your certificate and provisioning profile. App center needs your signing certificate as a .p12 file. Upload this .p12 file and enter the password you used.

3. Test on a real device: By turning this option on, your app will be launched on a real device inside the App Center’s Test Cloud service, and the test will verify that your app is launched successfully. It will just launch the app and check for a crash. This is a great sanity check that your build has worked and that your app at least starts up. You have no control over which device it will run on, it will be a compatible one with at least your app’s minimum SDK installed, but other than that you have no control. It will also make your build take longer, as you will have to wait for an available device.

4. Distribute Builds: These options allow you to distribute final builds to either beta testers or the store.

To create a distribution group, select Groups from the distribute menu on left side of the App Center home page. Here, you will find a button in the upper right hand corner: New Group. Create and name your group (e.g., Alpha Testers) . Enter email addresses into the box labeled Who would you like to invite to this group? Each of the invited person will receive an invitation via email.

When you hit Save & Build, App Center will start to build from the last commit on the configured branch. You can configure many builds from different branches, with only one concurrent build per app.

While it is running, there will be a blue circle in the upper left of the build window, with the three dots animated to show you it is working.

When it is done, you’ll see one of the three circles

  • A grey circle with a line through it indicating that you cancelled the build
  • A dreaded red circle with an x, indicating that your build failed
  • A wonderful green circle with a check mark, indicating that your build has succeeded

Here we are Done. You can commit your code and it will automatically build and distribute your respective group or store.

I hope you have understood how to implement Continuous Integration (CI) and Deployment (CD) using App Center. Next time we are going to look at more features of App Center : Crashes & Analytics

Thanks for reading.

--

--

No responses yet