Using CAB Wizard to Package an Application


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.

USING VISUAL STUDIO .NET AND THE CAB WIZARD TOGETHER TO CREATE A CAB FILE

One great way to build a CAB file for your application is to use both Visual Studio .NET and the CAB Wizard. You can first use Visual Studio .NET to create the configuration file. This file is output into the <project_name>/obj/<build_type> directory. See the "Using Visual Studio .NET to Package an Application" section for details. Then you can edit the configuration file to customize your CAB file. Finally, you can use the BuildCab.bat file, also output in the <project_name>/obj/<build_type> directory, which uses the CAB Wizard to rebuild your 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

DIRECTORY MACRO

WINDOWS CE DIRECTORY

%CE1%

\Program Files

%CE2%

\Windows

%CE4%

\Windows\StartUp

%CE5%

\My Documents

%CE8%

\Program Files\Games

%CE11%

\Windows\Start Menu\Programs

%CE14%

\Windows\Start Menu\Programs\Games

%CE15%

\Windows\Fonts

%CE17%

\Windows\Start Menu

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.

Signature Must be either "$Windows NT$" or "$Windows 95$". It does not matter which string you choose, making this key almost useless.

Provider It is recommended that this be the name of the company that is creating the application. This is recommended because the value will be displayed during installation of the CAB.

CESignature Must be "$Windows CE$". This key seems almost as useless as the Signature key, but it may have some use in later versions of CAB Wizard.

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.

AppName The name of your application. Any further occurrence of %AppName% will be resolved to AppName 's value.

InstallDir The name of the default installation directory. Any further occurrence of %InstallDir% will be resolved to InstallDir 's value.

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 Key

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

  • filename is the name of the shortcut.

  • type is a numeric value. Zero represents a shortcut to a file, whereas any nonzero value represents a shortcut to a directory.

  • target defines the destination file or directory for the shortcut. If a file is specified, it must also be specified in the CopyFiles section. Use a file_list_section name as defined in the DestinationDirs section or the %InstallDir% substitution string.

  • destination defines the destination path for the shortcut file. Only a directory identifier from Table 16.1 or %InstallDir% can be used. This is optional, and if it is not specified, the shortcut file will be placed in the default directory destination, which is defined in the DestinationDir section.

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

  • disk_id is the source identifier used to specify the source directory. You will see this identifier again in the SourceDisksFiles section.

  • comment is a friendly description of the source directory.

  • path is the desktop file system path to where the application's files live.

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]

  • filename is the source filename.

  • disk_id is the source identifier defined in SourceDisksNames section.

  • subdir is the subdirectory under the disk_id directory that contains the file. The parameter is optional.

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

file_list_section The section that contains the list of files that will be installed in the location specified by the subdir parameter.

subdir The destination directory. The subdir key can be an absolute filepath, a directory macro, or the %InstallDir% macro. In the previous example, the files in the Shortcuts section are installed in the \Windows\Start Menu directory . The files from the Files.Common section and the Files.ARM section are installed in %InstallDir% .

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 graphics/ccc.gif .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 graphics/ccc.gif .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 graphics/ccc.gif \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 graphics/ccc.gif .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 Wizard

Now 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 ]]

inf_file The full path and filename to the configuration file described in the previous sections.

dest_dir The directory where the CAB files will be placed. This parameter is optional, and if it is not supplied, the wizard will place the CAB file in the directory in which the configuration file was found.

error_file The name and absolute path of the file that the CAB Wizard will use to write information about errors that occur while creating the CAB file. This parameter is also optional, and if not specified, the Wizard will display the errors in message boxes. The CAB Wizard runs without UI if this parameter is specified.

platform_label If one or more of these parameters are specified, then a CAB file is created for each platform_label that you specify. The /cpu option must be the last option used on the command line.

The following example creates a CAB file for the ARM processor: Cabwiz.exe "c:\myApp\myconfig.inf" /err errors.txt /cpu arm .



Microsoft.NET Compact Framework Kick Start
Microsoft .NET Compact Framework Kick Start
ISBN: 0672325705
EAN: 2147483647
Year: 2003
Pages: 206

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net