Walkthrough: Packaging a Smart Device Solution for Deployment
This walkthrough demonstrates how to use Visual Studio to package your application and its resources into a CAB file so that it can be deployed to an end-user's smart device.
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.
In this walkthrough, you begin with any smart device solution written in Visual Basic, Visual C#, or Visual C++. For more information, see Walkthrough: Creating Windows Forms Applications for a Device.
This walkthrough shows how to do the following:
Add a CAB project to the solution.
Change the product name.
Change the output path.
Populate the CAB file by using the primary output of the application.
Add dependencies if they are required.
Create a shortcut to the application.
Move the shortcut to the Start menu or Programs folder.
Modify a registry entry.
An existing smart device solution. For purposes of this walkthrough, consider creating and building a simple project, such as the project described in Walkthrough: Creating Windows Forms Applications for a Device.
Setting Up the CAB Project
To add a Smart Device CAB project to the solution
Open the existing smart device project and make sure that Solution Explorer is visible.
On the File menu, point to Add, and then click New Project.
The Add New Project dialog box appears.
In the Project Types pane,expand Other Project Types, and then click Setup and Deployment.
In the Templates pane, click Smart Device CAB Project.
This is the only type of CAB project valid for smart devices. The other project types are for desktop solutions only.
In the Name box, type CABProject, and then click OK.
The CAB project is added to the solution and is visible in Solution Explorer. The two panes of the File System Editor are now displayed.
Customizing the CAB Project
To change the product name and other project properties
In Solution Explorer, click CABProject if it is not selected already.
On the View menu, click Properties Window to open the Properties window.
In the ProductName field of the property grid, change the value to MyProduct.
The value of the ProductName property determines the name that is displayed for the application in folder names and in the Add or Remove Programs dialog box.
You can also use this window to change the name of the manufacturer and to specify the minimum and maximum versions of the operating system.
You can set the OSVersionMin property to 4.21 to indicate that your Pocket PC application has screen orientation awareness. However, by setting this property to 4.21 you will prevent the application from installing on Pocket PCs based on Windows Mobile 2003 and earlier. To allow for installation on such devices and also indicate screen orientation awareness to newer devices, you must manually modify the .inf file to set the BuildMax property to one of the following values:
0xA0000000 to indicate the application supports square screens (240x240 pixels)
0xC0000000 to indicate the application supports screen rotation
0xE0000000 to indicate the application supports square screens and screen rotation.
For more information, see the Developing Screen Orientation-Aware Applications article on MSDN.
For Pocket PC solutions that are based on Windows Mobile 2003 SE and earlier, the Compress property and the NoUninstall Device Deployment property must be false. Please note this option can be set to true for devices equipped with Compact Framework 2.0. For more information, see Properties Window, Smart Device Cab Project.
If you are using a Windows CE setup DLL, use this property grid to specify the file name and location. For more information about Windows CE setup DLLs, see the Pocket PC or Smartphone SDK documentation.
To change the CAB file name and add authentication
In Solution Explorer, right-click CABProject, and then click Properties.
The Property Pages dialog box appears for your CAB project. In the Output file name box, change the name of the CAB file and path to Debug\MyApp.cab, and then click OK.
You can also use this property page to add authentication to your project. Authentication is required for Smartphone solutions and is not supported on Pocket PC solutions that are based on Windows Mobile 2003 SE and earlier. For more information, see Security in Device Projects.
To add the device project application to the CAB project
In the left pane of the File System Editor, click Application Folder to specify that the files you select in the following steps will be installed into this folder on the target device.
If you cannot see the File System Editor, right-click the CAB project name in Solution Explorer, click View, and then click File System.
On the shortcut menu in Visual Studio, point to Add, and then click Project Output.
In the Add Project Output Group dialog box, select your Smart Device Project from the Project drop-down list.
From the list of outputs, select Primary output, and then click OK.
When creating a Smart Device CAB project for an application written in C++, you must manually add dependencies, such as atl90.dll, mfc90U.dll, and/or msvcr.dll, to the CAB project if you are dynamically linking to these DLLs. However, static linking is strongly recommended in order to reduce dependencies on the MFC/ATL DLLs. If you are statically linking, the DLLs should not be redistributed with your application. If you are dynamically linking and have to redistribute the DLLs in the CAB, do not install the DLLs to the system directory, such as \windows, on the device. Instead, install the DLLs in the local application directory. If you are redistributing a suite of applications, which all dynamically link to the ATL/MFC run times, install all applications and the run-time DLLs to a single application directory, and provide shortcuts to the applications that can be put in their own folders. This will save some size and avoid the danger of the DLLs in the system directory being replaced later and breaking applications that dynamically link to them.
To add dependencies to the CAB project (C++ projects only)
In Solution Explorer, right-click your CAB project name, point to Add, and click File.
Navigate to Visual Studio installation folder\VC\ce\dll\platform.
Select the files to add.
For an MFC project, press CTRL, and click MFC90U.DLL, atl90.dll, and msvcr90.dll. You may also have to click one or more of the language-specific DLLs if your application requires MFC language-specific resources.
For an ATL project, press CTRL, and click atl90.dll and msvcr90.dll. If your ATL solution supports MFC, click MFC90U.DLL also.
For a Win32 project, click msvcr90.dll.
Click Open in the Add Files dialog box to add the files to your CAB project.
In the left pane of the File System Editor, right-click File SystemonTarget Machine.
Click Add Special Folder, and then click Windows Folder.
In the left pane of File System Editor, click the folder that contains your primary output. The DLLs have been added by default to the same folder as your primary output. To move them to the Windows folder, select the files in the center pane of the File System Editor, drag them over to the Windows Folder icon.
Use the same procedure to add other dependencies that are required by your solution. You can add dependencies to any folder; you do not have to add them to the Windows folder.
To create a shortcut for the device project application
In the right pane of the File System Editor, select Primary output from <your application project name>.
On the shortcut menu, click Create Shortcut to Primary output from <your application project name>.
This command adds a Shortcut item under the Output item.
Right-click the Shortcut item, click Rename, and rename the shortcut to something appropriate for a shortcut.
To move the shortcut to the Start menu or Programs folder
In the left pane of the File System Editor, right click File System on Target Machine, point to Add Special Folder, and click Start Menu Folder or Programs Folder.
Drag the shortcut from the Application Folder to the Start Menu Folder or Programs Folder.
To add a registry entry
In Solution Explorer, click the CAB project.
On the View menu, point to Editor, and then click Registry.
In the Registry Editor, right-click HKEY_CURRENT_USER, and then click New Key.
When the New Key entry is displayed in the Registry Editor, rename it to SOFTWARE.
Right-click this new key, point to New, and then click Key.
When the New Key entry is displayed in the Registry Editor, rename it to MyCompany.
Right-click the MyCompany entry, and then click Properties Window.
The Name value has been changed to MyCompany.
Building and Deploying the CAB File
To build the CAB file
On the Build menu, click Build CABProject.
Right-click CABProject in Solution Explorer, and click Build.
On the File menu, click Save All.
CAB files for Smartphone solutions must be digitally signed before they are deployed to an end-user's device. Digital signing is not supported on Pocket PC solutions that are based on Windows Mobile 2003 SE and earlier. For more information, see How to: Sign a CAB File (Devices).
To deploy the CAB file to the device
In Windows Explorer, navigate to the folder where you stored this solution. You will find the CAB file in the CABProject\Debug folder of your solution.
Copy the CAB file to a device that is connected by using ActiveSync 4.0 or later versions.
When a user taps on the CAB file name in File Explorer on the device, Windows CE will explode the CAB, and install the application on the device.
For more information, see the Smartphone and Pocket PC SDK documentation.
Packaging (How Do I in Smart Devices)