Deploying applications to Windows Mobile

I thought I would be a little different and make my first post as useful as possible by including some of my latest work. I guess I cant totally skip the intro bit tho: My name is Marcus Perryman and I've been working with or for Microsoft in the UK for the last 8 years in various technical roles including C++ product support, internal systems development, application development consultancy for the last 5 years and in the Developer & Platform Community team for the last 5 days! Code is my passion and my way of life. My first love is C/C++ and I often find myself still reverting to it although C# is fast becoming my new love. I have never really got on well with VB and it still scares the hell out of me when presented with a page of complex VB code ... total respect for anyone that can!

I guess I will always have a passion for small, shiny toys that can run my code and for 4 years now I have focused on Windows Mobile Pocket PC's and Smartphones. My bag is rarely found with less than 4 mobile devices and I have a relatively full museum of devices for those devices I don’t carry on a particular day (more another day maybe). I can still clearly remember the day Mike Hall brought his AutoPC (remember that device?) into the office and 30 mins later we had 'hello world' up and running... there was no looking back!

So what are you likely to see on my Blog? I guess it’s inevitably going to be mainly mobile stuff to start with but I am hoping to try something new over the next 6 months and I'm digging into ASP.NET 2.0 to see what all those web developers get so excited about. Lets see how things progress.

Anyway, onto the useful stuff. I contribute to the UK MSDN Flash news letter that is sent out every couple of weeks and have just done a piece on deployment to mobile devices. There is a lot in there for Windows Mobile to cover pretty much every eventuality but I find that most developers are usually only aware of some options. MSDN flash articles are tightly restricted in length so I've just covered the basics.

"Deploying Mobile Device Applications

Mobile applications require many of the same engineering considerations as other development paradigms but some areas such as deployment bring their own, unique challenges due to the very mobile nature of devices. During development of managed and native applications both Visual Studio .NET 2003 and Embedded Visual C++ deal with deployment to a device over Active Sync very adequately but much more is needed to distribute and manage final product deployment.

 

First of all let’s consider the basic components needed to deal with deployment to Windows Mobile powered devices:

 

Cabinet Files

The first step to deployment involves packaging all the required components and configuration information into a simple manageable form. Windows Mobile provides support for the Cabinet (CAB) file technology which is the predecessor to MSI on the desktop. CAB’s are a concatenation of files, configuration information and an install script that define the destination for files, list registry key changes, create shortcuts to your applications and even allow you to run code during the install. Installation with a CAB file has the added benefit of automatically creating an uninstall option based on the CAB install script and deploying via a CAB file is required to achieving Windows Mobile logo certification.

 

Creating CAB Files

Three things are required to create a CAB file: your deployment components; a .INF file that describes how to build those components into a CAB file; and the ‘cabwiz’ utility that ships with many different products including Visual Studio .NET 2003 and Embedded Visual C++.

 

Visual Studio .NET provides a neat facility to assist in creating CAB files: select the menu Build | Build CAB File and Visual Studio .NET 2003 will create an INF file for all the components of the selected project including multiple processor targets, and it even creates a batch file for you. This is a great starting point for you to extend to include other components of your application. For a full description of CAB file capabilities click here.

 

Getting the CAB File to your Device

ActiveSync includes a facility called Application Manager that provides a transparent mechanism to install and remove applications from a connected device and is an ideal solution for deploying ISV applications such as games and utilities. To use Application Manager you must provide a simple INI file that describes your application including the CAB files that need to be installed, and then call CEAppMgr.exe with the name and location of your INI file. This step would normally take place as the last step of a desktop installer such as an MSI package. For more information about Application Manager click here.

 

For the Enterprise Connected Device?

Enterprise situations are somewhat different as devices are less likely to have an ActiveSync partnership. In this case CAB files can be deployed via e-mail attachments or as intranet downloads. Ideally the process should be a little more complete and include remote management of the device. Today there are a number of solutions in the marketplace for device management including Microsoft SMS 2003 with the advent of the Device Management Feature Pack. This free add-on to SMS 2003 SP1 provides all the basic management features such as hardware and software inventory, password policy and device settings management as well as being able to deploy your shiny new CAB file over the air. For more information about SMS 2003 Device Management Feature Pack click here for the download page or here for an on-demand web cast of the main product features.

 

Disconnected Devices?

For disconnected devices removable media might be the only option to deploy applications. In this case we can make use of a feature of Windows CE that detects when a storage card is inserted or removed from the device and if present, a processor specific version of Autorun.exe is copied to the windows directory and automatically run. This provides the ideal mechanism to automatically start the installation of cab files placed on the card. For more information about Autorun click here.

 

Summary

Remember, the first step is to build your CAB file. Make this part of the daily build right from the start of your project and you will see the benefits throughout the development cycle. Choosing a deployment technique requires knowledge of your target device, but every scenario is catered for.

 

Bye for now"

 

Let me know if there is anything in Windows Mobile (or ASP.NET 2.0) you have a specific interest in and I will endeavour to share what I know.

Marcus