How do I zip a folder in MSBuild?
msbuild
Solution
"MSBuild.Community.Tasks.Zip" is one way. WorkingCheckout and OutputDirectory are not defined.
But you can get the drift below.
The below will get all files that are not .config files for my zip.
Note "Host" is my custom csproj folder name, yours will be different.
<ItemGroup>
<ZipFilesHostNonConfigExcludeFiles Include="$(WorkingCheckout)\Host\bin\$(Configuration)\**\*.config" />
</ItemGroup>
<!-- -->
<ItemGroup>
<ZipFilesHostNonConfigIncludeFiles Include="$(WorkingCheckout)\Host\bin\$(Configuration)\**\*.*" Exclude="@(ZipFilesHostNonConfigExcludeFiles)" />
</ItemGroup>
<MSBuild.Community.Tasks.Zip Files="@(ZipFilesHostNonConfigIncludeFiles)" ZipFileName="$(OutputDirectory)\MyZipFileNameHere_$(Configuration).zip" WorkingDirectory="$(WorkingCheckout)\Host\bin\$(Configuration)\" />
<!-- -->
Here is the other main-stream option:
http://msbuildextensionpack.codeplex.com/discussions/398966
Problem
How do I zip an output folder in MSBuild? For the filename I need to use a variable that gets set elsewhere.