4
votes

So, we're working through the Visual Studio CTP for Hybrid apps. The version with the CTP is 3.4.0 of Cordova. There are a number of fixes which we need to do app testing with and have been made in 3.5.0. Does anyone know how to update the cordova version to 3.5 inside Visual Studio (or even outside Visual Studio) to work with the new CTP functionality?

Thanks

3

3 Answers

3
votes

Update Cordova on Windows

Note: Make sure you close all instances of Visual Studio before starting this process.

  1. Download and install the latest version of Node.js from nodejs.org.
  2. Update npm. To check your current npm version run the following command in a console:

    npm -v

    To update to the last version of npm run the following command in a console (elevated As Administrator):

    npm install -g npm

  3. Update Cordova. To check your Cordova version run the following command in a console:

    cordova -v

    To update to the last version of cordova run the following command in a console (elevated As Administrator):

    npm install -g cordova

  4. Update the vs-mda version of Cordova with the latest you just installed in the previous step. Cordova is (globally) installed at %APPDATA%\npm\node_modules\cordova. vs-mda copy of Cordova is available at %APPDATA%\npm\node_modules\vs-mda\node_modules\cordova. Replace the entire content of this folder with the one of the global Cordova installation.

    1. Install missing modules (this might depend on the latest version you install). For 5.3.3 I had to install concat-map and balanced-match. If anything else is necessary it should show up in the output log when you build your Cordova project.

    npm install -g concat-map

    npm install -g balanced-match

Update Cordova on Mac

Note: Make sure you stop the vs-mda-remote agent before performing this upgrade.

  1. Open a Terminal session and run the following command:

    sudo npm update -g cordova

  2. Update the vs-mda-remote version of Cordova with the the latest you just installed in the previous step. Cordova is (globally) installed at /usr/local/lib/node_modules/cordova. vs-mda-remote copy of Cordova is available at /usr/local/lib/node_modules/vs-mda-remote/node_modules/cordova. Replace the entire content of this folder with the one of the global Cordova installation.
  3. Restart the vs-mda-remote agent.

With all these installed you should be all set to start building with the latest version of Cordova.

NOTE

Pay attention if you clear cordova cache from Visual studio options menu, you need to do this procedure again. because it will copy older version into (for me 4.0.0) %APPDATA%\npm\node_modules\vs-mda\node_modules\cordova

2
votes

NOTE: This works for all the platforms EXCEPT iOS. There's something hard coded somewhere else that I am still looking for. But for Android, Windows, etc (anything you can cpompile on Windows) this does solve the problem.

in %APPDATA%\npm\node_modules\vs-mda\node_modules\cordova\ there is a file called "platforms.js" In there are the URLs and versions used for each of the platforms for cordova. use the URL (on github) to check which specific versions you have/need - for example iOS had a 3.4.1. build, but android and WP7 did not. So don't just blindly change them all. Exit Visual Studio. Go into your project directory and delete everything in the bld directory. Now restart VS. Do a CLEAN on the project and then BUILD/RUN it - in the log you should see that the platform gets downloaded AND that the batch file run (create.bat) is now the new version. Hope they make this easier in the release...

2
votes

To update the iOS platform version:

  1. From a Command Prompt on your Windows machine, run the following command: npm install -g cordova
  2. Replace the VS-MDA version of the Cordova package repository (%APPDATA%\npm\node_modules\vs-mda\node_modules\cordova\node_modules\cordova-lib) with the new ones downloaded into the global repository (%APPDATA%\npm\node_modules\cordova).
  3. Perform steps above to use the newer version (exit VS, delete bld directory files, restart VS, Clean Solution, Build Solution). Now everything on the Visual Studio side should be using the updated Cordova version.
  4. On the Mac, open a Terminal session and run the following command: sudo npm update -g cordova
  5. Replace the VS-MDA-Remote version of the Cordova package repository (/usr/local/lib/node_modules/vs-mda-remote/node_modules/cordova) with the new ones downloaded into the global repository (/usr/local/lib/node_modules/cordova).
  6. Shut down the VS-MDA-Remote agent (if it is still running) and start it again. Your Mac should now be using the updated Cordova version too.

When you build your next version of your app in Visual Studio both sides of the build process should be using the new Cordova version (4.2.0 at the time of this posting) or else VS will stop with a build error notifying you of the version mismatch.

Edit Sept 4, 2015: The RTM version of the Cordova tools that ships with VS2015 will automatically update the iOS side as well on build. No manual updating is necessary.