Section 8.2. Creating CAB Files


8.2. Creating CAB Files

The cab task creates Microsoft .cab archive files, and you use this task as you would the jar or zip tasks. The .cab files are the .NET equivalent of .war files, packaging .NET applications for server deployment. This task works in Windows using the external cabarc tool (this tool comes from Microsoft), which must be in your executable path.

I'm not going to spend much time on this task because the Microsoft Visual Studio IDE has many powerful integrated build tools and wizards that create .cab files; most Microsoft developers do not need Ant to solve their build problems. Here's a quick example using the Ant cab task:

<cab cabfile="${deploy}/app.cab"     basedir="${output}" />

You can get a free copy of the Microsoft C# command-line compiler, csc, if your version of Windows doesn't have it. Install the .NET Framework's Software Development Kit (SDK), which you can find at http://msdn.microsoft.com/downloads. The csc compiler is included.


The attributes of the cab task appear in Table 8-2.

It's possible to use this task on other platforms besides Windows, but you need to get and compile the libcabinet tool from http://trill.cis.fordham.edu/~barbacha/cabinet_library/.


Table 8-2. The cab task's attributes

Attribute

Description

Required

Default

basedir

Specifies the directory to archive files from.

No

 

cabfile

Specifies the name of the cab file you want to create.

Yes

 

compress

Specifies you want to not only store data but compress it.

No

yes

defaultexcludes

Specifies if you want to use default excludes or not. Set to yes/no.

No

Default excludes are used.

excludes

Specifes the patterns matching files to exclude, as a comma- or space-separated list.

No

 

excludesfile

Specifes the name of a file where each line is a pattern matching files to exclude.

No

 

includes

Specifes the patterns matching files to include, as a comma- or space-separated list.

No

 

includesfile

Specifes the name of a file where each line is a pattern matching files to include.

No

 

options

Specifies any additional command-line options you want to pass to the cabarc tool.

No

 

verbose

Specifies you want full (verbose) output. Set to yes or no.

No

no


You can use nested fileset elements to specify the files to be included in the archive. As with other Ant tasks, this task forms an implicit FileSet and supports all attributes of the fileset element (dir becomes basedir) as well as the nested include, exclude and patternset elements.



    Ant. The Definitive Guide
    Ant: The Definitive Guide, 2nd Edition
    ISBN: 0596006098
    EAN: 2147483647
    Year: 2003
    Pages: 115
    Authors: Steve Holzner

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