Using TFS with Xamarin (Walkthrough)
How to do Continuous Integration with a Xamarin project and TFS
Let us know how you feel about this.
last updated: 2015-11
This document walks through the process of creating a Continuous Integration (CI) workflow that builds a Xamarin app using a self-hosted Team Foundation Server. It covers taking an existing solution, attaching it to a TFS Team Project, and automating the build and unit testing of checked-in source code.
As discussed in the document Introduction to CI, Continuous Integration (CI) is a software development practice where members of a team integrate their work frequently. Each integration is verified by an automated build (including running tests) to detect integration errors as quickly as possible.
Microsoft’s Visual Studio Team Services (VSTS) and Team Foundation Server (TFS) are popular Application Lifecycle Management (ALM) products used to support development practices. Both provide the tools required to effectively manage software development projects throughout their complete lifecycle.
For Xamarin projects, you can use VSTS and TFS either separately or together. With VSTS by itself, you create build definitions for each individual Xamarin platform for which you have a license. With TFS, you can use any edition including TFS Express. For instructions on setting up a local TFS machine, see Configuring TFS for Xamarin.
In this section we'll now walk through using a configured TFS host with a Xamarin project:
- Preparing an existing cross-platform Xamarin project for TFS.
- Creating a new TFS Team Project and attaching the Xamarin project.
- Adding unit testing.
- Creating a TFS build definition to automate the build and running tests.
- Checking-in code and testing our build definition.
- Working with TFS and Xamarin Studio for Mac.
Before beginning this walkthrough, make sure you've completed the requirements described on Configuring TFS for Xamarin topic. This includes making sure that the Android SDK and NDK are installed on the TFS machine in an accessible location, which is described in Configuring the TFS Server to Build Android Apps
For this walkthrough we’ll be using the simple TaskyPortable cross-platform sample app, which tracks todo/task items. It illustrates proper app architecture layering and uses a common code base for the Business Layer (BL), Data Access Layer (DAL), and Data Layer (DL) layers. It separates out the User Interface (UI) and Application Layer (AL) into the appropriate device-apps.
TaskyPortable is part of the greater Mobile Samples repository. Click Download as ZIP on the repository page, then extract the ZIP contents to a suitable location on your development machine. This collection contains many samples demonstrating code sharing between Android, iOS, and Windows projects.
You'll find the TaskyPortable solution in the TaskyPortable folder. (Note that TaskyPortable is very similar to the Tasky sample that is also in the collection, but implements all its shared code in a portable class library (PCL)).
Open the TaskyPortable solution now in Visual Studio so you can proceed with the following sections of this walkthrough:
- Preparing Xamarin.Android – Creates a pre-build event to ensure that versions of TFS prior to 2013 can build the Xamarin.Android project. This step is not necessary if you're working with TFS 2013 or later.
- Creating the TFS Team Project – Creates a TFS Team Project to house the solution in version control.
- Adding a Build Definition – Creates a build definition in the team project to build and test the app.
- Working with TFS from Mac OS X – Demonstrates working with the team project in Eclipse and Team Explorer Everywhere on a Mac.