Makecab.exe is a tool that is included in Windows 2000 or later. To use makecab.exe to create a. cab file, perform the following steps:
Create a targeted file for makecab.exe and save the file with the. DDF extension. The following sample targeting file (named sample. DDF) creates a. cab file for a simple Web Part Library Project:
; *** Sample source code makecab directive file example
;
. Option explicit; generate errors
. Set cabinetnametemplate = samplecab. Cab
. Set diskdirectorytemplate = CDROM; All cabinets go in a single directory
. Set compressiontype = mszip; ** all files are compressed in cabinet files
. Set uniquefiles = "off"
. Set cabinet = on
. Set diskdirectory1 = samplecab. Cab
Manifest. xml
Webpart1.dwp
Webpartlibrary1.dll
; *** <The end>
Copy all the files you want to include in the. cab file to the directory where the. DDF file is created. In this example, these files are manifest. XML files, webpart1.dwp files, and webpartlibrary1.dll files.
Open a command prompt, go to the directory that contains the. DDF file and the file you want to include in the. cab file, and then run the following command:
Makecab.exe/F sample. DDF
Makecab.exe creates a directory named samplecab. Cab, and creates a. cab file named samplecab. Cab in the directory, which contains the three files listed in the sample. DDF targeting file.
For more information about makecab.exe, download microsoft cabinet software development kit.
Use a localized resource to create a cab file
Visual Studio does not support creating. CAB files that contain internal directories. However, a localized web part may need a. cab file containing an internal directory. Therefore, you must use a tool such as makecab.exe or another third-party cab utility to deploy localized web components.
The following example describes how to create a. cab file for an English Web Part project named samplewebpartlibrary (which also provides German localization resources. In this example, the. cab file name is sample. Cab, which must contain the following files:
Samplewebpartlibrary. dll
Help.htm
Image1.gif
Webpart1.dwp
De-de/help.htm
De-de/image1.gif
De-de/webpart1.dwp
To create a. cab file for this example web part project, perform the following steps:
1.
Create an appropriate manifest. xml file. The following example shows the manifest. xml file of the sample. cab file:
<? XML version = "1.0" encoding = "UTF-8"?>
<Webpartmanifest
Xmlns = "http://schemas.microsoft.com/WebPart/v2/Manifest">
<Assemblies>
<Assembly filename = "samplewebpartlibrary. dll">
<Classresources>
<Classresource filename = "image1.gif"/>
<Classresource filename = "help.htm"/>
<Classresource filename = "de-de/image1.gif"/>
<Classresource filename = "de-de/help.htm"/>
</Classresources>
<Safecontrols>
<Safecontrol namespace = "samplewebpartlibrary"
Typename = "*"/>
</Safecontrols>
</Assembly>
</Assemblies>
<Dwpfiles>
<Dwpfile filename = "webpart1.dwp"/>
<Dwpfile filename = "de-de/webpart1.dwp"/>
</Dwpfiles>
</Webpartmanifest>
2.
Create an appropriate targeted makecab.exe file. The following example shows the targeted file of the sample. cab file:
; *** Sample source code makecab directive file example
;
. Option explicit; generate errors
. Set cabinetnametemplate = sample. Cab
. Set diskdirectorytemplate = CDROM; All cabinets go in a single
Directory
. Set compressiontype = mszip; ** all files are compressed in Cabinet
Files
. Set uniquefiles = "off"
. Set cabinet = on
. Set diskdirectory1 = sample. Cab
Manifest. xml
Webpart1.dwp
Samplewebpartlibrary. dll
Image1.gif
Help.htm
Set destinationdir = de-de
De-de/webpart1.dwp
De-de/image1.gif
De-de/help.htm
; *** <The end>
3.
Copy all the files you want to include in the. cab file to the directory where the. DDF file is created, and copy all the local resources to the corresponding subdirectory. The following example shows the directory structure of the sample. cab file:
/Directory with Directive File
Sample. DDF
Manifest. xml
Samplewebpartlibrary. dll
Webpart1.dwp
Image1.gif
Help.htm
/De-de
Webpart1.dwp
Image1.gif
Help.htm
4.
Open a command prompt and go to include. DDF file and. the Directory of the file in the cab file, and then run the following command in the sample. create a subdirectory in the cab file and prepare the sample for deployment. cab file:
Makecab.exe/F sample. DDF