Tuesday, 25 November 2014

Multi-Device Hybrid Applications - Upgrading to CTP3

To upgrade to CTP 3 you need to first uninstall CTP 2.

To uninstall:

Step 1
  • Open Visual Studio 2013
  • Select Tools > Extensions and Updates,  "Multi-Device Hybrid Apps for Visual Studio"
  • Click Uninstall
Step 2
  • Open Programs and Features
  • Search for "Multi Device...
  • Right Click Uninstall
Step 3

Follow the steps in this Microsoft KB.

Finally CTP 2 is gone...

You should now be able to install CTP 3.

Just a note about the uninstall process.  On my work machine I uninstalled from within Visual Studio 2013 only and then upgraded to Visual Studio 2013 update 4.  I then tried to install CTP 3 and was prompted to remove CTP 2.  I tried to remove CTP 2 via Programs and Features and then had to follow the steps in the KB.  On my home machine, I followed Steps 1 and 2 above and CTP 2 uninstalled properly the first time.

Wednesday, 12 November 2014

Multi-Device Hybrid Applications - Side load your application

I have reach the point in my current project where I needed to get my application up and running on a device for testing.  There are a number of articles out there on how to side load a Windows Store application, but I didn't find any that specifically dealt with multi-device hybrid applications.

The first device I managed to get my hands on for testing purposes is the Windows Surface RT running Windows 8.1 so the steps for side loading in this post are what worked for me on the RT, but should be the same for any other Windows 8.1 tablet.

The steps for side loading are as follows (assuming your multi-device project name is myProj):

Create the deployment package
  • Build your solution
  • Navigate to MyProj/bld/Debug/platforms/windows8/
  • Copy the AppPackages folder to your memory stick
  • Copy the AppPackages folder to your device
THE SHORT
  • In Window Explorer: Navigate to AppPackages\CordovaApp_1.0.0.0_AnyCPU_Debug_Test
  • Press on the Add-AppxDevPackage.ps1 and release. A context menu should appear.
  • Tap the "Run with Powershell" menu item
  • A powershell window should open
  • Type:Add-AppxDevPackage.ps1
  • Hit Enter and your application should install
If for whatever reason this is not the case continue reading.

THE LONG

Install the certificate
  • On the device navigate to the AppPackages\CordovaApp_1.0.0.0_AnyCPU_Debug_Test folder
  • Double tap on the CordovaApp_1.0.0.0_AnyCPU_Debug.cer security certificate
  • The Certificate installation dialog should appear
  • Tap on Install Certificate...
  • Under Store Location select Local Machine
  • Tap Next
  • Select place all certificates in the following store
  • Tap Browse...
  • Select Trusted People
  • Tap Ok, Tap Next, Tap Finish
  • You should get a popup with the message "The import was successful."
Run Powershell as an administrator
  • Tap the Windows key
  • From the Windows 8 start screen type: powershell
  • Press on the Windows Powershell application link that appears below the search box
  • Let go after a brief pause and a context menu should appear
  • Tap run as administrator
Ensure you have a developer license installed on the device
  • Type: Show-WindowsDeveloperLicenseRegistration
  • A window will appear and you will be prompted to enter your user name and password that is associated with your Microsoft developers license
  • Enter your user name and password
  • If you have the correct developers license you should be granted a developers license on the device.

Install the Appx package
  • In the powershell window navigate to the AppPackages\CordovaApp_1.0.0.0_AnyCPU_Debug_Test folder
  • Type: Add-AppDevPackage.ps1
  • Hit enter
  • If you receive and error about "running scripts is disabled"
  • Type: Set-ExecutionPolicy RemoteSigned
  • Type: Y
  • Hit Enter
  • Type: Add-AppDevPackage.ps1
NOTE: If you are installing your application on a device where the current user is not an administrator and after installation you can't find the application, open a new powershell session, but not as an administrator and then Type: Add-AppDevPackage.ps1

NOTE2: If you open the Add-AppDevPackage.ps1 in your favorite text editor, the comments in the file give you an idea of what

That should be it.





Tuesday, 11 November 2014

Multi-Device Hybrid Applications - The certificate specified has expired exception

I ran into a rather nasty little problem when trying to build my multi-device hybrid application yesterday. Out of the blue the build started to fail with the following exception message:

Error 3 The certificate specified has expired. For more information about renewing certificates, see http://go.microsoft.com/fwlink/?LinkID=241478. [D:\dev\client\source\myApp\bld\Debug\platforms\windows8\CordovaApp.jsproj] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\AppxPackage\Microsoft.AppXPackage.Targets 1772

I had just been trying to deploy the application to a device for the first time and thought I may have done something to mess up the certificate when I deployed to my local machine and then uninstalled the deployment. As it turns out this wasn't the case. I eventually posted a question on stackoverflow and was surprised to get a response with the answer so quickly.

Apparently, due to some coding error, the Windows Cordova platform has a temporary key that expired on 11/11/2014.  Microsoft is actively working on resolving the issue.

In the interim, the solution as explained in the answer to my question on stackoverflow is to create a new key and use this in your multi-device hybrid application.  To create a new key simply create a new Windows Store project in Visual Studio.  You will find the key in the root directory of the project. It's the file ending _TemporaryKey.pfx.  At this point the answer on stackoverflow wasn't immediately clear to me.  So just to clarify if you also found the answer a little bit confusing.  What you need to do is.


  • Rename the key from the Windows Store application (the _TemporaryKey.pfx) to Cordova_TemporaryKey.pfx.
  • In your multi-device hybrid application project navigate to the res/cert folder and add a folder windows8 (CTP1 and CTP2, see stackoverflow answer for CTP3 folder location).
  • Copy the Cordova_TemporaryKey.pfx into the res/cert/windows8 folder.
That should be all you need to do.  Now when you build you application this temporary key will be used when creating the certificate.