Last week I stumbled upon Luce Carters interesting Youtube Tutorial Setting up VSTS CI for Xamarin Forms. It’s very well explained, so if you prefer to watch it as a video: Switch over to Luces Tutorial! Otherwise here is a written step-by-step guide how to setup continuous Integration (CI) with Visual Studio Team Services (VSTS) for a Xamarin Forms App.
- In VSTS, go to “Build and Release” -> “Build” and select “New”.
- Source is of course “VSTS Git” so select project, repository and default branch.
- Now select your platform. You’ll find UWP, Xamarin Android and Xamarin iOS. My Xamarin Forms app only has iOS and Android projects, so I start with iOS now. It’s quite the same for both Android and iOS, difference is shown below.
- VSTS created some default tasks for your CI.
- Take care for iOS: In Task “Build Xamarin iOS Solution”, you have to check “Build for iOS Simulator”, otherwise your build will fail with error “/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(644,3): error : No valid iOS code signing keys found in keychain. You need to request a codesigning certificate from https://developer.apple.com.”
- Take care for Android: If you don’t have a test project, disable the test build!
- Go to tab “Triggers” and tick “Enable continuous integration”.
- Go to tab “Save & queue” and select “Save & queue”
- Enter some comment if you like and click “Save & queue”.
- VSTS confirms that the build has been saved. You could click on the link to see the current status. As this takes some minutes, you might instead want to go ahead and do the same for Android (and maybe UWP) now.
- After some minutes you should get an email with the test results.
That’s it! From now on, everytime you submit code to VSTS, it will automatically build the apps and send you a test result. Very easy steps to ensure the quality of the code.
How to add local DLLs
I’m still using James Montemagnos Contacts Plugin which does not exist as nuget package so I’ve referenced local DLLs. For CI to work, it’s important that you add the local DLLs to your source control. Take care that the reference then uses a relative path in your .csproj file.
Suddenly my builds fail. Reason is explained in the build report: With a free VSTS Account, you only have up to 240 minutes per month. Therefore I’ve now disabled CI because it’s confusing to get a failure report on every checkin.