This documentation is archived and is not being maintained.

Walkthrough: Packaging a Smart Device Solution for Deployment 

This walkthrough demonstrates how to use Visual Studio 2005 to package your application and its resources into a CAB file so that it can be deployed to an end-user's smart device.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

In this walkthrough, you begin with any smart device solution written in Visual Basic 2005, Visual C# 2005, or Visual C++ 2005. For more information, see Walkthrough: Creating a Simple Application.

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 with the primary output of the application.

  • Add dependencies if necessary.

  • Create a shortcut to the application.

  • Edit a registry entry.

An existing Smart Device solution. For purposes of this packaging walkthrough, consider creating and building a simple project, such as the project described in Walkthrough: Creating Windows Forms Applications for a Device.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To add a Smart Device CAB project to the solution

  1. Open the existing Smart Device Project and make sure that Solution Explorer is visible.

  2. On the File menu, point to Add, and then click New Project.

    The Add New Project dialog box appears.

  3. In the Project Types pane on the left, expand the Other Project Types node, and click Setup and Deployment.

  4. Under the Templates pane on the right, select 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.

  5. In the Name box, type CABProject, and then click OK.

    The CAB project is added to your solution and is visible in Solution Explorer. The two panes of the File System Editor are now displayed.

To change the product name and other project properties

  1. In Solution Explorer, select CABProject if it is not selected already.

  2. On the View menu, click Properties Window to open the Properties window.

  3. 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 allowed 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 installation on such devices and also indicate screen orientation awareness to newer devices, you must manually edit 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

      -or-

      0xE0000000 to indicate the application supports square screens and screen rotation.

      For more information, see the MSDN whitepaper Developing Screen Orientation-Aware Applications.

    • For Pocket PC solutions based on Windows Mobile 2003SE 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 on Windows CE setup DLLs, see the Pocket PC or Smartphone SDK documentation.

To change the CAB file name and add authentication

  1. 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.

  2. 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 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

  1. In the left pane of the File System Editor, select the Application Folder node to specify that the files you select in the following steps will be installed into this folder on the target device.

    If the File System editor is not visible, right-click the CAB project name in Solution Explorer, select View, and click File System.

  2. On the Action menu in Visual Studio, point to Add, and then click Project Output.

  3. In the Add Project Output Group dialog box, select your Smart Device Project from the Project drop-down list.

  4. From the list of outputs, select Primary output, and then click OK.

NoteNote

When creating a Smart Device CAB project for an application written in C++, you must manually add any dependencies, such as atl80.dll, mfc80U.dll, and/or msvcr.dll, to the CAB project if you are dynamically linking to these DLLs. Static linking is strongly recommended, however, 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 need 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 into the local application directory. If you are redistributing a suite of applications, all of which dynamically link to the ATL/MFC run times, it is recommended to install all the applications, and the run-time DLLs, to a single application directory, and provide shortcuts to the applications that can be placed in their own folders. This will save some size while avoiding the danger of the DLLs in the system directory being replaced later and breaking any applications that dynamically link to them.

To add dependencies to the CAB project (C++ projects only)

  1. In Solution Explorer, right-click on your CAB project name, then point to Add, and click File.

  2. Navigate to <Visual Studio installation folder>\VC\ce\dll\<platform>.

  3. Select the files to add.

    • For an MFC project, press CTRL, and click MFC80U.DLL, atl80.dll, and msvcr80.dll. You may also need 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 atl80.dll and msvcr80.dll. If your ATL solution supports MFC, click MFC80U.DLL also.

    • For a Win32 project, click msvcr80.dll.

  4. Click Open in the Add Files dialog box to add the files to your CAB project.

  5. In the left pane of the File System Editor, right-click File System on Target Machine.

  6. Click Add Special Folder, and then click Windows Folder.

  7. 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.

  8. Use the same procedure to add any other dependencies required by your solution. You can add dependencies into any folder; it is not necessary to add them to the Windows folder.

To create a shortcut for the device project application

  1. In the right pane of the File System Editor, select Primary output from <your application project name>.

  2. On the Action menu, select Create Shortcut to Primary output from <your application project name>.

    This command adds a Shortcut item below the Output item.

  3. Right-click the Shortcut item, click Rename, and rename the shortcut to something suitable for a shortcut.

To add a registry entry

  1. In Solution Explorer, select the CAB project.

  2. On the View menu, point to Editor, and then click Registry.

  3. In the Registry Editor, right-click HKEY_CURRENT_USER, and then click New Key on the shortcut menu.

  4. When the New Key entry is displayed in the Registry Editor, rename it to SOFTWARE.

  5. Right-click this new key, point to New, and then click Key.

  6. When the New Key entry is displayed in the Registry Editor, rename it to MyCompany.

  7. Right-click the MyCompany entry, and then click Properties Window on the shortcut menu.

    The Name value has been changed to MyCompany.

To build the CAB file

  1. On the Build menu, click Build CABProject.

    -or-

    Right-click CABProject in Solution Explorer, and click Build.

  2. 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 based on Windows Mobile 2003SE and earlier. For more information, see How to: Sign a CAB File (Devices).

To deploy the CAB file to the device

  1. In Windows Explorer, navigate to the folder where you stored this solution. You will find the CAB file in the CABProject\Release folder of your solution.

  2. Copy the CAB file to a device that is connected with ActiveSync 4.0 or later.

    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.

Show: