The out of the box Cordova windows visual studio template does not product an artefact which can be deployed through an MDM, this presentation shows it can be modified to achieve this goal
2. Problems
Out of the box Cordova Windows Phone project has the following enterprise
issues:
Airwatch upload didn’t recognise the Appx file as a Windows Phone app
Dependencies not automatically downloaded
Requires a redundant dummy DLL which is only used to sign the app
Product ID not configurable
Intune can only upgrade Appx files and not Appxbundles
3. Fixing Cordova
Two options
1. Fix default Cordova template to handle enterprise deployment
Push our changes back to the open source community
2. Alter the Cordova build after the default template is pulled down using the built in
hook mechanism
Chose option 2
No delays in waiting for approval from community
Hook mechanism easy to understand – allows custom code to be executed during
various points of the execution process
Implemented a number of pre-compile hooks
Hooks written in Javascript executed by Nodejs
4. Uploading Windows Phone Appx files to
Airwatch
Airwatch expects the TargetFrameworkMoniker build:Item to be present in the
AppxManifest
AppxManifest is a generated artifact of the MSBuild process
Solution:
Write a Cordova Windows pre-compile hook to alter the CordovaApp.Phone.jsproj file
Added:
<TargetFrameworkIdentifier>WindowsPhoneApp</TargetFrameworkIdentifier>
<TargetFrameworkVersion>8.1</TargetFrameworkVersion>
to the section:
<PropertyGroup Label=“Configuration”>
5. Dependencies not automatically downloaded
Enterprise Windows app do not automatically download Javascript dependencies
Cordova requires the WinJS dependency to enable it to launch a webview
Solution:
Download the latest version of the WinJS library
Write a Windows pre-compile hook to add files to the Cordova Windows template
Alter the index.html file of the app to reference the WinJS files included in the project
6. Redundant dummy DLL
Required for the sign process in order to produce a CodeIntegrity.cat file
In order to make the code upgradable, the DLL must have a different version
number and have a code change for each new app version
Solution
Create a simple DLL project in Visual Studio with a simple class file
Write a Cordova Windows pre-compile hook which
Adds a new method to the simple class file
Alters the version number of the DLL
Compiles the DLL using MSBuild
Adds the resultant artifact to default Cordova Windows Template
7. Configurable Phone Product ID
Microsoft Intune identified an application’s uniqueness by the phone product ID
GUID found in the AppxManifest file
Windows Cordova template generates a new product ID for every build
Solution:
Write a Windows Cordova pre-compile hook to take a configurable product ID GUID
8. Intune can only upgrade Appx files
Cordova builds an Appxbundle by default
Appxbundles contain multiple Appx files, often for internationalisation
Airwatch can only upload Appx files and Intune can only upgrade Appx files
Solution:
Write a Windows Cordova pre-compile hook
Add <AppxBundle>Never</AppxBundle> to the CordovaApp.Phone.jsproj file
9. Conclusion
Just because Microsoft supports Cordova and has Cordova templates built into
Visual Studio, it does not mean it will be compatible with Microsoft’s Intune MDM
when used out of the box
Cordova Hooks can be very useful
Alter the jsproj file to change what is put into the Appxmanifest file