Testing your Windows Mobile application on real devices could not be easier. All you need is to:
1. Connect your device to your development machine using ActiveSync.
2. Select Windows Mobile 6 Standard Device (see Figure 18-20) in Visual Studio 2008.
Figure 18-20
3. Press F5. The application is now deployed onto the device.
Deploying the Application
Once the testing and debugging process is over, you need to package the application nicely so that you have a way to get it installed on your users' devices.
The following sections show how to create a CAB (cabinet) file — a library of compressed files stored as a single file — so that you can easily distribute your application. Subsequent sections explain how to create an MSI (Microsoft Installer) file to automate the installation process.
An easy way to package your Windows Mobile application is to create a CAB file so that you can transfer it onto the end user's device (using emails, web browser, memory card, and so on). The following steps show you how:
1. Add a new project to the current solution in Visual Studio 2008 (see Figure 18-21).
Figure 18-21
2. Choose the Setup and Deployment project type, and select the Smart Device CAB Project template (see Figure 18-22). Use the default name of SmartDeviceCab1, and click OK.
Figure 18-22
3. In the File System tab, right-click on Application Folder, and select Add→Project Output (see Figure 18-23).
Figure 18-23
4 . Select the RSSReader
project, and click Primary output (see Figure 18-24). Click OK. This adds the output of the RSSReader project (which is your executable application) to the current project.
Figure 18-24
5. Right-click on the output item shown on the right-side of the File System tab, and create a shortcut to it (see Figure 18-25). Name the shortcut RSSReader.
Figure 18-25
6 . Right-click the File System on Target Machine item, and select Add Special Folder→Start Menu Folder (see Figure 18-26).
Figure 18-26
7. Drag and drop the RSSReader shortcut onto the newly added Start Menu Folder (see Figure 18-27). This ensures that when the CAB file is installed on the device, a shortcut named RSS Reader appears in the Start menu.
Figure 18-27
8. Right-click on the SmartDeviceCab1 project name in Solution Explorer, and select Properties. Change the Configuration from Debug
to Release
. Also, name the output file Release\RSSReader.cab (see Figure 18-28).
Figure 18-28
9. In Visual Studio 2008, change the configuration from Debug to Release (see Figure 18-29).
Figure 18-29
10. Finally, set the properties of the SmartDeviceCab1
project as shown in the following table (see Figure 18-30).
Property |
Value |
Manufacturer |
Developer Learning Solutions |
ProductName |
RSS Reader v1.0 |
Figure 18-30
That's it! Right-click on the SmartDeviceCab1
project name in Solution Explorer and select Build. You can find the CAB file located in the \Release
folder of the SmartDeviceCab1
project (see Figure 18-31).
Figure 18-31
Now you can distribute the CAB file to your customers using various media such as FTP, web hosting, email, and so on. When the user clicks on the RSSReader CAB file in File Explorer (on the device; see Figure 18-32), the application will ask if he wants to install it onto the device, or onto the storage card (if available).
Figure 18-32
When the application is installed, the RSS Reader shortcut is in the Start menu (see Figure 18-33).
Figure 18-33
Creating a Setup Application
Although you can deploy CAB files directly to your users, you might want to use a more user-friendly way using the traditional setup application that most Windows users are familiar with — users simply connect their devices to their computers and then run a setup application, which then installs the application automatically on their devices through ActiveSync.
Creating a setup application for a Windows Mobile application is more involved than for a conventional Windows application because you have to activate ActiveSync to install it. Figure 18-34 shows the steps in the installation process.
Figure 18-34
First, the application containing the CAB files (and other relevant files) must be installed on the user's computer. Then ActiveSync needs to install the application onto the user's device.
The following sections detail how to create an MSI file to install the application onto the user's computer and then onto the device.
Creating the Custom Installer
The first component you will build is the custom installer that will invoke ActiveSync to install the application onto the user's device. For this, you will use a Class Library project.
Add a new project to your current solution by going to File→Add→New Project. Select the Windows project type and select the Class Library template. Name the project RSSReaderInstaller (see Figure 18-35). Click OK.
Figure 18-35
Delete the default Class1.cs
file and add a new item to the project. In the Add New Item dialog, select the Installer Class template, and name the file RSSReaderInstaller.cs
(see Figure 18-36).
Читать дальше