Valid TaskActions are:

AddFiles (Required: ZipFileName, CompressFiles or Path Optional: CompressionLevel, MaxOutputSegmentSize, Password; RemoveRoot, UseZip64WhenSaving) Existing files will be updated

Create (Required: ZipFileName, CompressFiles or Path Optional: CompressionLevel, MaxOutputSegmentSize, Password; RemoveRoot, UseZip64WhenSaving)

Extract (Required: ZipFileName, ExtractPath Optional: Password)

Remote Execution Support: NA

This task uses http://dotnetzip.codeplex.com v1.9.1.8 for compression.

Namespace: MSBuild.ExtensionPack.Compression
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0

Examples

CopyXML
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
    <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
  </PropertyGroup>
  <Import Project="$(TPath)"/>
  <Target Name="Default" DependsOnTargets="Sample1;Sample2"/>
  <Target Name="Sample1">
    <ItemGroup>
      <!-- Set the collection of files to Zip-->
      <FilesToZip Include="C:\Patches\**\*"/>
    </ItemGroup>
    <!-- Create a zip file based on the FilesToZip collection -->
    <MSBuild.ExtensionPack.Compression.Zip TaskAction="Create" CompressFiles="@(FilesToZip)" ZipFileName="C:\newZipByFile.zip"/>
    <MSBuild.ExtensionPack.Compression.Zip TaskAction="Create" Password="apassword" CompressionLevel="BestCompression" RemoveRoot="C:\Patches" CompressFiles="@(FilesToZip)" ZipFileName="C:\newZipByFileBestCompression.zip"/>
    <!-- Create a zip file based on a Path -->
    <MSBuild.ExtensionPack.Compression.Zip TaskAction="Create" CompressPath="C:\Patches" ZipFileName="C:\newZipByPath.zip"/>
    <!-- Extract a zip file-->
    <MSBuild.ExtensionPack.Compression.Zip TaskAction="Extract" ExtractPath="C:\aaa11\1" ZipFileName="C:\newZipByFile.zip"/>
    <MSBuild.ExtensionPack.Compression.Zip TaskAction="Extract" ExtractPath="C:\aaa11\2" ZipFileName="C:\newZipByPath.zip"/>
    <MSBuild.ExtensionPack.Compression.Zip TaskAction="Extract" Password="apassword"  ExtractPath="C:\aaa11\3" ZipFileName="C:\newZipByFileBestCompression.zip"/>
  </Target>
  <Target Name="Sample2">
    <PropertyGroup>
      <SourceDirectory>MotorData\</SourceDirectory>
    </PropertyGroup>
    <ItemGroup>
      <Files Include="$(SourceDirectory)*" Exclude="$(SourceDirectory).XYZ\**\*">
        <Group>Common</Group>
      </Files>
      <Files Include="$(SourceDirectory)Cars\*" Exclude="$(SourceDirectory)Cars\.XYZ\**\*">
        <Group>Cars</Group>
      </Files>
      <Files Include="$(SourceDirectory)Trucks\*" Exclude="$(SourceDirectory)Trucks\.XYZ\**\*">
        <Group>Trucks</Group>
      </Files>
    </ItemGroup>
    <!-- Create the output folder -->
    <ItemGroup>
      <OutputDirectory Include="output\"/>
    </ItemGroup>
    <MakeDir Directories="@(OutputDirectory)"/>
    <PropertyGroup>
      <WorkingDir>%(OutputDirectory.Fullpath)</WorkingDir>
    </PropertyGroup>
    <!-- Zip files based on the group they belong to -->
    <MSBuild.ExtensionPack.Compression.Zip TaskAction="Create" CompressFiles="@(Files)" ZipFileName="$(WorkingDir)%(Files.Group).zip"/>
  </Target>
</Project>

Inheritance Hierarchy

System..::..Object
  Microsoft.Build.Utilities..::..Task
    MSBuild.ExtensionPack..::..BaseTask
      MSBuild.ExtensionPack.Compression..::..Zip

See Also