Continuous Integration and Continuous Delivery for Xamarin.iOS With VSTS
Jakub Jedryszek shares his experiences using Visual Studio Team Services to support Continuous Integration and Continuous Delivery for Xamarin.
Join the DZone community and get the full member experience.
Join For Freevisual studio team services has great continuous integration and continuos delivery support for xamarin. recently, i was configuring pipeline that would build the project, run unit tests (with xunit), run ui tests (with xamarin test cloud), and, if all tests pass, deploy a new version of the app to hockey app. during the process of creating the vsts build definition, i encountered a few problems that i think are worth to share with you.
to make a basic build definition with building xamarin.ios project and deploying to hockey app with vsts+xamarin check james montemagno’s continuous integration for ios apps with visual studio team services first.
here are the issues i had that were not described anywhere online:
- i couldn’t use the visual studio test task for running xunit tests because every build definition on vsts can be executed by only one build agent, and to build a xamarin project, i needed the mac build agent.
- how to run ui tests (with xamarin test cloud) using the same build that would be later on deployed to hockey app. test cloud requires init code that later on shouldn’t be present in deployed app.
running xunit tests with mac build agent
this requires adding two tasks to build definition:
- command line task to run tests with mono and xunit console runner.
- publish test results task to display results in build summary.
first, install xunit console runner nuget package. to run tests, add a command line task with following settings:
- tool: mono
- arguments: packages/xunit.runner.console. 2.1.0 /tools/xunit.console.exe yourapp .unittests/bin/debug/ yourapp .unittests.dll -xml unittestsresults.xml
remember to replace yourapp with your app name and set the same xunit runner version that you have installed.
to publish test results, add the publish test results task with the following settings:
- test result format: xunit
- test result files: **/unittestsresults.xml
- always run: true
running xamarin ui tests with test cloud before deploying to hockeyapp
the solution there is rather simple: build in debug mode that has test_cloud preprocessor directive defined, run tests, and then build again in release mode before deploying to hockey app.
delete files before build
for a while, i couldn’t figure out why my tests are not passing when they were run from vsts while they passed on my machine. it turned out, vsts was using old builds for tests. i am not sure about macincloud , but if you are using your own build agent running on your mac, the directories that contain binary files are not being cleaned up before next build automatically. to avoid using old builds, you can add, at the beginning of your pipeline, a delete files task and delete everything from bin/* and obj/* .
summary
the final build definition looks like this:
let me know if i missed some details; i would be happy to add them! also, if you know a better way of doing this, let me know as well!
Published at DZone with permission of Jacob Jedryszek, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments