FAKE - F# Make - A DSL for build tasks and more FAKE
6.0.0

Lookig for older versions of the documentation, pre FAKE v6? See 

v5.fake.build

Zip Module

This module contains helper function to create and extract zip archives.

Functions and values

Function or value Description

Zip.DefaultZipLevel

Full Usage: Zip.DefaultZipLevel

Returns: int

The default zip level

Returns: int

Zip.createZip workingDir fileName comment level flatten files

Full Usage: Zip.createZip workingDir fileName comment level flatten files

Parameters:
    workingDir : string - The relative dir of the zip files. Use this parameter to influence directory structure within zip file.
    fileName : string - The fileName of the resulting zip file.
    comment : string - A comment for the resulting zip file (currently ignored in fake 5 and above).
    level : int - The compression level.
    flatten : bool - If set to true then all subfolders are merged into the root folder.
    files : seq<string> - A sequence with files to zip.

Creates a zip file with the given files

workingDir : string

The relative dir of the zip files. Use this parameter to influence directory structure within zip file.

fileName : string

The fileName of the resulting zip file.

comment : string

A comment for the resulting zip file (currently ignored in fake 5 and above).

level : int

The compression level.

flatten : bool

If set to true then all subfolders are merged into the root folder.

files : seq<string>

A sequence with files to zip.

Zip.createZipOfIncludes fileName comment level files

Full Usage: Zip.createZipOfIncludes fileName comment level files

Parameters:
    fileName : string - The file name of the resulting zip file.
    comment : string - A comment for the resulting zip file (currently ignored in fake 5 and above).
    level : int - The compression level.
    files : seq<string * IGlobbingPattern> - A sequence of target folders and files to include relative to their base directory.

Creates a zip file with the given files.

fileName : string

The file name of the resulting zip file.

comment : string

A comment for the resulting zip file (currently ignored in fake 5 and above).

level : int

The compression level.

files : seq<string * IGlobbingPattern>

A sequence of target folders and files to include relative to their base directory.

Zip.createZipSpec fileName comment level items

Full Usage: Zip.createZipSpec fileName comment level items

Parameters:
    fileName : string - The fileName of the resulting zip file.
    comment : string - A comment for the resulting zip file (currently ignored in fake 5 and above).
    level : int - The compression level.
    items : seq<string * string> - A sequence with files and their target location in the zip.

Creates a zip file with the given files and specs.

fileName : string

The fileName of the resulting zip file.

comment : string

A comment for the resulting zip file (currently ignored in fake 5 and above).

level : int

The compression level.

items : seq<string * string>

A sequence with files and their target location in the zip.

Zip.filesAsSpecs workingDir files

Full Usage: Zip.filesAsSpecs workingDir files

Parameters:
    workingDir : string - The relative dir of the zip files. Use this parameter to influence directory structure within zip file.
    files : IGlobbingPattern - A sequence of target folders and files to include relative to their base directory.

Returns: seq<string * string>

This helper helps with creating complex zip file with multiple include patterns. This method will convert a given glob pattern with the given workingDir to a sequence of zip specifications.

workingDir : string

The relative dir of the zip files. Use this parameter to influence directory structure within zip file.

files : IGlobbingPattern

A sequence of target folders and files to include relative to their base directory.

Returns: seq<string * string>
Example

The following sample creates a zip file containing the files from multiple patterns and moves them to different folders within the zip file.


 Target "Zip" (fun _ ->
         [   !! "ci/build/project1/**/*"
                 |> Zip.filesAsSpecs "ci/build/project1"
                 |> Zip.moveToFolder "project1"
             !! "ci/build/project2/**/*"
                 |> Zip.filesAsSpecs "ci/build/project2"
                 |> Zip.moveToFolder "project2"
             !! "ci/build/project3/sub/dir/**/*"
                 |> Zip.filesAsSpecs "ci/build/project3"
                 |> Zip.moveToFolder "project3"
         ]
         |> Seq.concat
         |> Zip.zipSpec (sprintf @"ci/deploy/project.%s.zip" buildVersion)
     )

Zip.filesAsSpecsFlatten files

Full Usage: Zip.filesAsSpecsFlatten files

Parameters:
    files : IGlobbingPattern - A sequence of target folders and files to include relative to their base directory.

Returns: seq<string * string>

This helper helps with creating complex zip file with multiple include patterns.

files : IGlobbingPattern

A sequence of target folders and files to include relative to their base directory.

Returns: seq<string * string>
Example

The following sample creates a zip file containing the files from multiple patterns and moves them to different folders within the zip file.


 Target "Zip" (fun _ ->
         [   !! "ci/build/project1/**/*"
                 |> Zip.filesAsSpecsFlatten
                 |> Zip.moveToFolder "project1"
             !! "ci/build/project2/**/*"
                 |> Zip.filesAsSpecsFlatten
                 |> Zip.moveToFolder "project2"
             !! "ci/build/project3/sub/dir/**/*"
                 |> Zip.filesAsSpecs "ci/build/project3"
                 |> Zip.moveToFolder "project3"
         ]
         |> Seq.concat
         |> Zip.zipSpec (sprintf @"ci/deploy/project.%s.zip" buildVersion)
     )

Zip.moveToFolder path items

Full Usage: Zip.moveToFolder path items

Parameters:
    path : string
    items : seq<string * string>

Returns: seq<string * string>

This helper helps with creating complex zip file with multiple include patterns. This function will move a given list of zip specifications to the given folder (while keeping original folder structure intact).

path : string
items : seq<string * string>
Returns: seq<string * string>
Example

The following sample creates a zip file containing the files from multiple patterns and moves them to different folders within the zip file.


 Target "Zip" (fun _ ->
         [   !! "ci/build/project1/**/*"
                 |> Zip.filesAsSpecsFlatten
                 |> Zip.moveToFolder "project1"
             !! "ci/build/project2/**/*"
                 |> Zip.filesAsSpecsFlatten
                 |> Zip.moveToFolder "project2"
             !! "ci/build/project3/sub/dir/**/*"
                 |> Zip.filesAsSpecs "ci/build/project3"
                 |> Zip.moveToFolder "project3"
         ]
         |> Seq.concat
         |> Zip.zipSpec (sprintf @"ci/deploy/project.%s.zip" buildVersion)
     )

Zip.unzip target fileName

Full Usage: Zip.unzip target fileName

Parameters:
    target : string - The target directory.
    fileName : string - The file name of the zip file.

Unzips a file with the given file name.

target : string

The target directory.

fileName : string

The file name of the zip file.

Zip.unzipFirstMatchingFileInMemory predicate zipFileName

Full Usage: Zip.unzipFirstMatchingFileInMemory predicate zipFileName

Parameters:
    predicate : ZipArchiveEntry -> bool - The predicate for the searched file in the archive.
    zipFileName : string - The file name of the zip file.

Returns: string

Unzips a single file from the archive with the given file name.

predicate : ZipArchiveEntry -> bool

The predicate for the searched file in the archive.

zipFileName : string

The file name of the zip file.

Returns: string

Zip.unzipSingleFileInMemory fileToUnzip zipFileName

Full Usage: Zip.unzipSingleFileInMemory fileToUnzip zipFileName

Parameters:
    fileToUnzip : string - The file inside the archive.
    zipFileName : string - The file name of the zip file.

Returns: string

Unzips a single file from the archive with the given file name.

fileToUnzip : string

The file inside the archive.

zipFileName : string

The file name of the zip file.

Returns: string

Zip.zip workingDir fileName files

Full Usage: Zip.zip workingDir fileName files

Parameters:
    workingDir : string - The relative dir of the zip files. Use this parameter to influence directory structure within zip file.
    fileName : string - The file name of the resulting zip file.
    files : seq<string> - A sequence with files to zip.

Creates a zip file with the given files.

workingDir : string

The relative dir of the zip files. Use this parameter to influence directory structure within zip file.

fileName : string

The file name of the resulting zip file.

files : seq<string>

A sequence with files to zip.

Zip.zipFile fileName targetFileName

Full Usage: Zip.zipFile fileName targetFileName

Parameters:
    fileName : string - The file name of the resulting zip file.
    targetFileName : string - The file to zip.

Creates a zip file with the given file.

fileName : string

The file name of the resulting zip file.

targetFileName : string

The file to zip.

Zip.zipOfIncludes fileName files

Full Usage: Zip.zipOfIncludes fileName files

Parameters:
    fileName : string - The file name of the resulting zip file.
    files : seq<string * IGlobbingPattern> - A sequence of target folders and files to include relative to their base directory.

Creates a zip file with the given files.

fileName : string

The file name of the resulting zip file.

files : seq<string * IGlobbingPattern>

A sequence of target folders and files to include relative to their base directory.

Example

The following sample creates a zip file containing the files from the two target folders and FileIncludes.

  • The files from the first FileInclude will be placed in the root of the zip file.
  • The files from the second FileInclude will be placed under the directory app_data\jobs\continuous\MyWebJob
in the zip file.

 Target "Zip" (fun _ ->
         [   "", !! "MyWebApp/*.html"
                 ++ "MyWebApp/bin/**/*.dll"
                 ++ "MyWebApp/bin/**/*.pdb"
                 ++ "MyWebApp/fonts/**"
                 ++ "MyWebApp/img/**"
                 ++ "MyWebApp/js/**"
                 -- "MyWebApp/js/_references.js"
                 ++ "MyWebApp/web.config"
             @"app_data\jobs\continuous\MyWebJob", !! "MyWebJob/bin/Release/*.*"
         ]
         |> Zip.zipOfIncludes (sprintf @"bin\MyWebApp.%s.zip" buildVersion)
     )

Zip.zipSpec fileName items

Full Usage: Zip.zipSpec fileName items

Parameters:
    fileName : string - The fileName of the resulting zip file.
    items : seq<string * string> - A sequence with files and their target location in the zip.

Creates a zip file with the given files and specs.

fileName : string

The fileName of the resulting zip file.

items : seq<string * string>

A sequence with files and their target location in the zip.