Although using Visual Studio .NET to create a CAB file is insanely easy, it is very inflexible . Using the CAB Wizard takes more time and understanding but provides great flexibility for building the CAB file. Before you can use the CAB Wizard, you must have a configuration file that tells the wizard how to build the CAB file. The configuration file has the .inf file extension and consists of a number of sections that describe the target locations of the files and shortcuts as well as registry settings that will be contained with the CAB file.
Throughout the .inf file you will need to specify filepaths for different installation points. The CAB Wizard has a set of macro strings that represent certain directories on the Windows CE file system. Table 16.1 lists these macros and their corresponding Windows CE directories. Table 16.1. Windows CE Directory Macros
The configuration file consists of several different sections that describe the files that will be placed in the CAB file. Each section is now described. Specifying the Application Version in the Version Section[Version] Signature = "signature_name" Provider = "provider_name" CESignature = "$Windows CE$" The Version section is used to specify the creator of the CAB file. The Version section must always be present in the configuration file.
Understanding the CEStrings Section[CEStrings] AppName = "Calc.NET" InstallDir = %CE1%\%AppName% The CEStrings section provides substitution strings for the application name and default installation directory. The CEStrings section is required.
In the earlier example this would be \Program Files\CalcDotNet . Specifying Custom Substitution Strings in the Strings Section[Strings] db_file = db.mdb config_file = config.xml The Strings section is used to define one or more custom substitution strings. Think of this section as a dictionary of custom substitution strings that can be used throughout the configuration file. This section can contain one or more entries. In the earlier example any occurrence of %db_file% or %config_file% will be replaced with db.mdb or config.xml , respectively. Understanding the DefaultInstall Section[DefaultInstall] CopyFiles = Files.Common CEShortcuts = Shortcuts [DefaultInstall.ARM] CopyFiles=Files.ARM CESetupDLL=vsd_setup.dll [Shortcuts] Calc.NET, 0, CalDotNet.exe [Files.Common] CalcDotNet.exe,,,0 [Files.ARM] vsd_setup.dll,,,0 The DefaultInstall section specifies the application files that will be installed. This section is required. Additional DefaultInstallation sections can be specified for the various processor types supported. In the earlier example the DefaultInstall.ARM section would define the default installation files for the ARM processor. The DefaultInstallation section can contain five different keys, but only one, CopyFiles , is required. The CopyFiles key defines the files that will be copied to the device when the application installs . The value is the name of a custom section that is declared in the configuration file. The custom section contains the list of files to be installed. In the example the File.Common section and the Files.ARM section define custom CopyFiles sections. The File.Common section tells the installer to copy the CalcDotNet.exe file, whereas the Files.Arm copies vsd_setup.dll . For more information on the CopyFiles section, see the Windows CE SDK documentation. The AddReg key adds entries into the registry when the application is installed. This section is optional. For more information, see the Windows CE SDK documentation. Specifying Application Shortcuts with the CEShortcuts KeyCEShortcuts defines the shortcuts that the installer creates on the device. The value of the CEShortcuts key is the name of a custom section that lists the shortcuts to create. In the previous example the Shortcuts section is this custom section. The Shortcuts section contains the list of shortcuts that will be created when the application is installed. A shortcut list entry takes the following form, as expanded upon in the list that follows : filename,type,target,destination .
In the earlier example, the shortcut named Calc.NET , which targets CalcDotNet.exe , is created in the default directory destination. Specifying the Desktop Location of the Application in SourceDisksNames Section[SourceDisksNames] 1 = ,"Common files",,C:\myApp\MyCommonFiles [SourceDisksNames.ARM] 2 = ,"ARM Files",,C:\MyApp\ARMFiles The SourceDisksNames section specifies the desktop paths to where the application files can be retrieved when the CAB file is being built. The SourceDisksNames section is required. The keys in this section take the following form: disk_id = ,comment, ,path
Additional sections that are processor specific can be specified by appending the suffix .ProcessorName to SourceDisksNames . In the previous example a SourceDisksNames section for the ARM processor is defined. The SourceDisksFiles Section[SourceDisksFiles] intro.wav=1,"\sounds" [SourceDisksFiles.ARM] sample_arm.exe=2, "\samples" The SourceDisksFiles section describes the name and path of the files for the application. The SourceDisksFiles is also required. The keys in this section take the following format: filename=disk_id[, subdir]
Additional sections that are processor specific can be specified by appending the suffix .ProcessorName to SourceDisksFiles . In the example a SourceDisksFiles section for the ARM processor is defined. Specifying the Final Application Destination Directory in the DestinationDirs Section[DestinationDirs] Shortcuts = 0, %CE17% Files.Common = 0, %InstallDir% Files.ARM = 0, %InstallDir% The DestinationDirs section is a required section that specifies the paths of the destination directories on the target device. The format of the entries in this section is as follows: file_list_section = 0,subdir
Listing 16.1 is a complete configuration file for the application Calc.NET. Listing 16.1 [View full width] [Version] Signature="$Windows NT$" Provider="Calc-Net-Company" CESignature="$Windows CE$" [CEStrings] AppName="Calc.NET" InstallDir=%CE1%\%AppName% [CEDevice] VersionMin=3.00 VersionMax=3.99 [DefaultInstall] CEShortcuts=Shortcuts CopyFiles=Files.Common [DefaultInstall.ARM] CopyFiles=Files.ARM CESetupDLL=vsd_setup.dll [DefaultInstall.SH3] CopyFiles=Files.SH3 CESetupDLL=vsd_setup.dll [DefaultInstall.MIPS] CopyFiles=Files.MIPS CESetupDLL=vsd_setup.dll [DefaultInstall.X86] CopyFiles=Files.X86 CESetupDLL=vsd_setup.dll [SourceDisksNames] 1=,"Common1",,"E:\Projects\Calc.NET\obj\Debug\" [SourceDisksNames.ARM] 2=,"ARM2",,"E:\Projects\Calc.NET\obj\Debug\" 3=,"ARM_Setup",,"E:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1 .0.5000\Windows CE\wce300\ARM\" [SourceDisksNames.SH3] 4=,"SH34",,"E:\Projects\Calc.NET\obj\Debug\" 5=,"SH3_Setup",,"E:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1 .0.5000\Windows CE\wce300\SH3\" [SourceDisksNames.MIPS] 6=,"MIPS6",,"E:\Projects\Calc.NET\obj\Debug\" 7=,"MIPS_Setup",,"E:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK \v1.0.5000\Windows CE\wce300\MIPS\" [SourceDisksNames.X86] 8=,"X868",,"E:\Projects\Calc.NET\obj\Debug\" 9=,"X86_Setup",,"E:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1 .0.5000\Windows CE\wce300\X86\" [SourceDisksFiles] Calc.NET.exe=1 [SourceDisksFiles.ARM] vsd_config.txt.ARM=2 vsd_setup.dll=3 [SourceDisksFiles.SH3] vsd_config.txt.SH3=4 vsd_setup.dll=5 [SourceDisksFiles.MIPS] vsd_config.txt.MIPS=6 vsd_setup.dll=7 [SourceDisksFiles.X86] vsd_config.txt.X86=8 vsd_setup.dll=9 [DestinationDirs] Files.Common=0,%InstallDir% Shortcuts=0,%CE2%\Start Menu Files.ARM=0,%InstallDir% Files.SH3=0,%InstallDir% Files.MIPS=0,%InstallDir% Files.X86=0,%InstallDir% [Files.Common] Calc.NET.exe,,,0 [Files.ARM] vsd_config.txt,vsd_config.txt.ARM,,0 vsd_setup.dll,,,0 [Files.SH3] vsd_config.txt,vsd_config.txt.SH3,,0 vsd_setup.dll,,,0 [Files.MIPS] vsd_config.txt,vsd_config.txt.MIPS,,0 vsd_setup.dll,,,0 [Files.X86] vsd_config.txt,vsd_config.txt.X86,,0 vsd_setup.dll,,,0 [Shortcuts] Calc.NET,0,Calc.NET.exe Running the CAB WizardNow that you can create and customize a configuration file, we can look at using the CAB Wizard, a command line tool with the following command syntax: cabwiz.exe " inf_file " [/dest dest_dir ] [/err err_file ] [/cpu platform_label [platform _label ]]
The following example creates a CAB file for the ARM processor: Cabwiz.exe "c:\myApp\myconfig.inf" /err errors.txt /cpu arm . |