Visual Studio Team Services (formerly Visual Studio Online) and Team Foundation Services (TFS) 2015 can be used for building and testing Cordova apps in a Continuous Integration (CI) environment thanks to a new cross-platform agent that supports OSX. This new agent enables you to use Visual Studio Team Services (VSTS) or TFS to build projects targeting Android, iOS, or Windows created using Tools for Apache Cordova or any Cordova compliant CLI like the Ionic, PhoneGap, or TACO CLI.
Visual Studio Team Services Extension for Cordova
This extension contains a set of VS Team Services "tasks" (or "build steps") that streamline setup when building Cordova based applications in a CI environment. These tasks can be used with either VSTS or TFS 2015 on-prem servers (see below) and are intended to work with any Cordova based project including, but not limited to, those created using Tools for Apache Cordova. The tasks:
- Are designed to work with Cordova and Cordova-like toolsets like Ionic
- Automatically acquire and cache the appropriate version of Cordova or related CLI (ex: Ionic) based on task settings or the contents of taco.json
- Enable simplified signing, certificate management, and packaging particularly for iOS
- Include support for Tools for Apache Cordova specific features
- Support the Android, iOS, Windows, and Windows Phone 8.0 (wp8) Cordova platforms
Quick Start
- After installing the extension, upload your project to VSTS, TFS, or GitHub.
- Go to your VSTS or TFS project, click on the Build tab, and create a new build definition (the "+" icon) and select the Empty template.
- Click Add build step... and select Cordova Build from the Build category
- Configure the build step - Check out the tool tips for handy inline documentation.
- Add a Demand under the General tab of xcode to force the build to run on OSX or cmd to force it to run on Windows as appropriate
Note: Be sure you are running version 0.3.10 or higher of the cross-platform agent and the latest Windows agent as these are required for VS Team Services extension to function. The VSTS hosted agent and MacinCloud agents will already be on this version.
Usage and Tutorials
See the following articles for details on using these tasks in VSTS/TFS:
- Cordova Build
- Cordova Command
- Ionic Command
- PhoneGap Command
##FAQ
Q: Android for Cordova 6.0.0 is failing to build when specifying a keystore path. How can I resolve this issue?
A: This is a due to a Cordova bug that was resolved in Cordova 6.1.0. Use Cordova 5.4.1 or upgrade to 6.1.0+ to resolve.
Q: Android for Cordova 6.0.0 is failing to build on a Mac or Linux. How can I resolve this issue?
A: This is a due to a Cordova bug that was resolved in Cordova 6.1.0. Use Cordova 5.4.1 or upgrade to 6.1.0+ to resolve.
Q: I am seeing Windows 10 builds fail in the VSTS Hosted Pool with a "Could not load file or assembly" error when using Cordova 5.4.x. How do I resolve this problem?
A: This is a Cordova bug when 64-bit Node.js is used. Upgrade to 6.1.0+ to resolve. See the Cordova bug for details.
Q: Building for Cordova 5.1.1 is failing with an ENOENT error. How can i resolve this issue?
A: This is due to a Cordova bug very specific to 5.1.1 where it fails to create some needed folders on a first time run. You can work around this in one of a few ways.
- Run another build with another version of Cordova. This will create the folders that 5.1.1 needs.
- Create the needed folders manually. By default, the folders that need to be created are ~/.taco_home/node_modules/_cordova/lib/npm_cache for OSX/Linux and %APPDATA%/taco_home/node_modules/_cordova/lib/npm_cache for Windows. Note that if CORDOVA_CACHE environment variable is set, the folder to be created is $CORDOVA_CACHE/_cordova/lib/npm_cache.
Q: After Feb 14th, I am seeing the following error when referencing P12 file: "Command failed: /bin/sh -c /usr/bin/security find-identity -v -p codesigning ..."
A: This is due to the Apple's WWDR certificate expiring on this date and an old certificate still being present on the system. To resolve, follow the steps outlined by Apple here. In particular, be sure to see "Xcode unable to create distribution builds for App Store submissions or Enterprise apps" and be sure to remove any expired certificates as this can cause the error to occur even after you've installed updated certificates. This also affects development certs despite the title.
Q: I am using my own Mac for a cross-platform agent and have it configured to run as a daemon. Signing is failing. How can I resolve this problem?
A: Configure the agent as a launch agent (./svc.sh install agent) or run it as an interactive process (node agent/vsoagent.js) to ensure Xcode is able to access the appropriate keychains. See the secure app signing tutorial for additional details. You could also opt to use MacinCloud instead.
Installation for TFS 2015 Update 1 or Earlier
See the source code repository for instructions on installing these tasks on TFS 2015 Update 1 or earlier.