ZipDirectory task

Creates a .zip archive from the contents of a directory.

Note

The ZipDirectory task is available in MSBuild 15.8 and above only.

Parameters

The following table describes the parameters of the ZipDirectory task.

Parameter Description
DestinationFile Required ITaskItem parameter

The full path to the .zip file to create.
Overwrite Optional Boolean parameter.

If true, the destination file will be overwritten if it exists. Defaults to false.
SourceDirectory Required ITaskItem parameter.

Specifies the directory to create a .zip archive from.

Remarks

In addition to the parameters listed above, this task inherits parameters from the TaskExtension class, which itself inherits from the Task class. For a list of these additional parameters and their descriptions, see TaskExtension base class.

Example

The following example (if used as an imported .targets file) creates a .zip archive from the output directory after building a project. The $(OutputPath) property would normally be defined in an MSBuild project file, so a project file that imports the following file would produce a zip archive output.zip:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <Target Name="ZipOutputPath" AfterTargets="Build">
        <ZipDirectory
            SourceDirectory="$(OutputPath)"
            DestinationFile="$(MSBuildProjectDirectory)\output.zip" />
    </Target>

</Project>

See also