TACOBOT

The Official Blog for Visual Studio
Tools for Apache Cordova

By our developers, for developers.

Announcing Update 5

Hello everybody, and welcome to our new developer blog! Today, I’m excited to announce the availability of Update 5 for the Tools for Apache Cordova. If you already have the tools installed then you can upgrade by clicking this link:

http://download.microsoft.com/download/F/2/3/F235B15D-C9FC-4297-A256-3FCDC37DD3EF/20160106.1/ApacheCordovaTools.exe

You can download the update now or wait a few weeks for the upgrade notification in Visual Studio. Cordova Update 5 does not require VS Update 1; however, if you install the update from the action center then the Visual Studio installer will require you to upgrade to VS update 1. The installer above will not install pre-requisites such as Node, Git and the Android SDK. You can install these manually if you like, but we suggest adding the tools from VS setup if you haven’t already before upgrading.

What’s New?

There are a lot of new features in this update. One of the things we’ve been focusing on lately is CLI interop. We want developers to be able to use Cordova from the command line and Visual Studio and have the same state reflected in both environments. The other thing we’ve been focusing on is Node 5 / NPM 3 and Cordova 5.4.1 / 6 compatibility.

So to address this, we added the following features to Update 5:

Allow VS to use the global Cordova version
By default, our tools use a sandboxed version of Cordova. This means that you could be using different versions of Cordova in VS than what you use on the command line. We’ve heard some feedback that this can create a confusing environment for some people. It means any changes made in the CLI are not automatically reflected in Visual Studio, for example. To address this, we added a checkbox in the config designer that lets you target the version you’ve installed globally:

Platform Version

If you check the checkbox, the version selection dropdown becomes disabled and shows you which version you have installed globally:

Global Platform Version

You’ll note that the dropdown is now grayed out and is displaying that the project will use the gobally installed Cordova version 5.3.3. You’ll also notice that we changed this from a text box to a dropdown menu so that we can pre-populate the available versions by querying NPM (although you can still enter whatever value you like in the dropdown).

CLI / VS Plugin Interop
For historical reasons, Visual Studio did not write the CLI-compatible <plugin> element to config.xml. This made for a confusing experience for some people who would add a plugin in VS and not see those changes reflect in the CLI and vice versa. To fix this, we changed our logic to write the same xml element as Cordova. This way, changes made in one environment show up in both.

As an example, adding the “File” plugin now writes this to config.xml:

<plugin name="cordova-plugin-file" version="3.0.0" />

Similarly, adding a plugin from the command line -

Command Line

Now reflects in the UI:

Added Plugin

Please note, Update 5 is forwards, but not backwards compatible. For example, if you added plugins to a project in Update 4 we will show that plugin as being added. But if you add a plugin in Update 5 and go back to Update 4, VS will not show the plugin as installed.

Build From the Command Line
We did some work in Update 5 so that Cordova projects can now be built from the command line using msbuild. This can address some CI scenarios, as well as customers who just like to build from a native command prompt. We are planning on publishing another blog post in the future detailing the parameters necessary to make this work.

iOS Build / Debug Improvements
We made a few improvements to our iOS story. First of all, we added support for the 6s simulator. We also improved the way we perform incremental remote builds to reduce build time - even across VS sessions.

Support for Node 5 / NPM 3
As you probably know, NPM 3 has recently been released. We are looking forward to a future when VS supports NPM 3 natively as we know the nested folder structure in earlier versions frequently hit MAX_PATH errors. Until then, we’ve been working on making sure our tooling works with NPM 3.

Unfortunately, NPM 3 does not work with Cordova versions 5.3.x and lower due to the removal of nested dependencies. We did some work to make this more visible. In Update 5, if you are targeting a Cordova version older than 5.4.0 and you have NPM 3 or higher, we will fail your build and show you an actionable message.

We also did some work in Update 5 to support Cordova 5.4.1 and 6.0 when it’s released. See the bug list below for more information.

Plugin Warning Bar
By default, adding a plugin to a Cordova project will ways add the latest version of that plugin. Unfortunately, this can be a big problem for customers who are targeting an older version of Cordova. In cases where there are major platform changes between the version they’re targeting and the edge version, the plugins may not be compatible with the platforms their Cordova version is targeting. Sometimes this results in obscure build errors.

The good news is that starting in Cordova 6.0.x, plugins will now be pinned to the platform that is pinned to that CLI. This means adding a plugin in Cordova 6 will no longer pull the edge version - it will pull a specific version that the Cordova community deemed compatible with 6.0.

Still, there are cases where developerss could be targeting a platform for which we do not have pinning data. We are discussing ways to make this experience smoother, but to start with we decided to alert developers when their configuration may not support the edge plugin version by adding an info bar to the config designer:

Plugin Warning Bar

We think the steps to resolve this problem are fairly mechanical, but we think the first step is to bring the potential problem to your attention. We would definitely appreciate feedback on the help link - we want this to be as easy to understand as possible.

In Update 5, we will show this info bar whenever you are targeting a Cordova version that is not on the latest version number. For example, if you are targeting 4.x and the latest is 5.x, then you will see this warning when you go to add a plugin. But you will not see it if you are targeting 5.3.3 and the latest is 5.4.1.

Cordova Version now in Help -> About
This is a small change but I thought I should mention it. We often ask customers which version of our tools they are on and the only way to know was to go into Add / Remove programs and look for our entry.

Starting in Update5, we now have an entry in Help -> About:

Help - About

Bug Fixes

There are a lot of bug fixes in this update. Here are the highlights:

Deploy to Ripple should error if VS is running as admin
We’re really happy to have a fix for this bug. Previously, we did not support deploying to Ripple if VS was run as administrator. The root cause of this was mismatched permissions between VS and the child processes we have to spawn to launch Ripple. This has been fixed in Update 5.

NullRef when dragging a snippet from HTML-DesignTools-Toolbox onto *.CSHTML file
We had a crash when dragging snippets into .cshtml files. We know this was particularly painful for customers who were using this feature for demos.

Cordova installs extra Node.exe package
We previously did not look for 64-bit Node version in our setup. This meant we would install our 32-bit version of Node even if you already had a 64-bit Node installed, and you could end up with two versions of Node installed. We’ve changed this - we’ll respect your 64-bit version if it’s already installed.

Latest Apache Cordova Tools is missing VS Android Emulator dependency
We had a setup authoring bug that prevented the VS Android Emulator for Android from being installed by default when Cordova was selected from setup.

Building a Cordova project does not trigger the before_build hook
We were not properly triggering this build hook in our tooling and this was preventing some plugins from working properly.

Plugin install error shows as Succeed in plugin window
We’ve been doing a lot of work to make plugin installation errors more diagnosable and transparent to customers. Bugs like this one were causing a lot of confusion - we would show success when in fact, the plugin failed to install.

MySQL breaks Cordova
Some customers reported strange path issues after installing MySQL. The root cause of the problem was that users’ PATH property could occasionally miss a semicolin and contain certain characters like “&”. We have fixed this in two ways. First, we added a diagnosable error message in cases where the PATH was malformed. And second, we have done some work to support PATH values with the ampersand character.

Store Packaging for Windows Phone 8.1 builds for x86 instead of ARM if Emulator is the debug target
We’ve fixed store packaging for Windows Phone so that it always targets ARM, no matter which debug target you have selected.

Feedback, and Thanks!

First of all, we hope you enjoy Update 5. As you can see, we’ve got a lot of good stuff here which we’re excited to ship to you. We aim to ship every sprint, so if everything goes well we’ll have Update 6 ready for you in three weeks.

We’ve also got lots and lots of content we’re looking forward to sharing on this blog. So please subscribe to the RSS feed and give us your feedback in the comments below. You can also email us at vscordovatools@microsoft.com.

See you next time!
Michael Braude
Development Manager | Tools for Apache Cordova
mbraude@microsoft.com | @LittleWebFoot