ZipDirectory task

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


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


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.


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.


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

<Project xmlns="">

    <Target Name="ZipOutputPath" AfterTargets="Build">
            DestinationFile="$(MSBuildProjectDirectory)\" />


See also