In Visual Studio 2005, the automatic CAB generation process has been replaced with a new feature called a Smart Device CAB Project. See the MSDN documentation for information about using the Smart Device CAB Project feature.
Visual Studio .NET 2003 has a Build CAB File feature that
you can use to automatically generate a redistributable CAB file.
This section of the tutorial explains how to use the automatic CAB
build process. After using the automatic CAB build process, you
must change some of the default settings. For example, the default
installation path of the application, the name of the Programs shortcut
icon, and the name of the Remove Programs screen entry for the client
contain default values such as My Company
.
You will customize the CAB file to reflect the names XYZ
Sales
and Unwired Accelerator
8.0
.
The process for making these customizations is two-fold. First, you must use the Build CAB File feature to generate an INF file to drive the CAB building process. After the INF file is created, you will customize it and use it to manually rebuild the XYZ Sales CAB file. You must manually generate the CAB after editing the INF file because if you use the Build CAB File feature in Visual Studio again, the INF file is overwritten with the original default settings, and you will lose your customized settings.
Generating the INF file
Build the project to make sure the latest version of the binary files are compiled and placed in the project’s temporary build folder named obj. The obj folder is automatically created in the project’s source code folder when you build the project.
Right-click the XYZSales project in the Solution Explorer and select Build CAB File.
After a moment, a series of command prompts appear and close. If successful, the Visual Studio Output window displays the following message:
" ------ Build Cab File: succeeded -----"
The next procedure shows how to customize the INF file that you generated in the obj folder. You will make the following customizations:
Installation Path – change to the installation directory of the application, for example Program Files\Sybase\UA 8\XYZ Sales.
Application title in the Remove Programs screen – change
to Sybase UA 8 XYZ Sales
.
Name of the shortcut in the Programs screen – change
to XYZ Sales
.
Customizing the INF file
Open the obj folder in Windows Explorer. If you are building a Release version, go into the Release folder. Similarly, if you are building a Debug version go into the Debug folder. If not explicitly set to Release, the project is set, by default, to Debug.
From the Debug or Release folder, locate and open the file named XYZSales_PPC.inf with Notepad or any other basic text editor.
Search for the line that says Provider=“My
Company”
and change it to Provider=“Sybase”
.
Locate the line that says AppName=“XYZSales”
and
change it to AppName=“UA 8 XYZ
Sales”
.
Locate the line that says InstallDir=%CE1%\%AppName%
and
change it to InstallDir=%CE1%\Program
Files\Sybase\UA 8\XYZ Sales
.
Near the bottom of the INF file, locate the line that says XYZ Sales,0,XYZ Sales.exe,%CE11% and change it to “Sybase UA 8 XYZ Sales,0,XYZ Sales.exe,%CE11%.”
A space was placed between “XYZ” and “Sales” in
the first part of this comma-delimited string. Do not add a space
to the second “XYZSales” because that is the name
of the EXE the shortcut will reference.
Save the INF file.
From a command prompt, navigate to the folder the INF file is in and run the BuildCab.bat script file.
The same command prompts you saw when you built the CAB from within Visual Studio reappear momentarily.
After the script is finished running and the command prompts have stopped opening and closing, the newly built CAB file is placed in a folder named cab. The cab folder is parallel to the obj folder under the project’s source code folder.
Using Windows Explorer, navigate to the cab folder. Depending on the Release/Debug setting you chose, there will be either a Debug or Release folder like there is under the obj folder. Go into the folder that is appropriate for the build version you are using.
Once you navigate into the appropriate Debug or Release folder, you see a set of multiple CAB files for different CPUs. The file for deploying to mobile devices is the CAB named XYZSales_PPC.ARMV4.CAB. If you are going to run this client on a Visual Studio 2003 emulator, use the XYZSales_PPC.X86.CAB file.
Deploying the CAB file to your PocketPC
CAB files must be transferred to your PocketPC before they can be installed. Open Microsoft ActiveSync, and open ActiveSync Explorer.
When the Mobile Device window appears, navigate to the location of the XYZSales_PPC.ARMV4.CAB file.
Right-click the XYZSales_PPC.ARMV4.CAB file, and select Copy.
Return to the Mobile Device explorer window, right-click in the right pane of the window and select Paste. The file is copied to your PocketPC.
Use the File Explorer application on the PocketPC to navigate to the location where you copied the file. Once you locate the file, tap it once to start the installation process.
The application is added to the Start | Programs menu.