1

I have to Zip my folders and subfolders Using MSbuild, I was looking at the MSBuild Extension pack, and tried this

 <ItemGroup>
  <ZipFiles Include="\Test\Web\**\*.*" >
    <Group>Release</Group>
  </ZipFiles>
 </ItemGroup>



 <MSBuild.ExtensionPack.Compression.Zip TaskAction="Create" CompressFiles="@(ZipFiles)" ZipFileName="$(WorkingDir)%(ZipFiles.Group).zip"/>

When I do this it just keep adding all the files to root, instead of adding it into the specific subfolder within the zip file.

I am missing something, can anyone help here please.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Manoj Talreja
  • 793
  • 3
  • 11
  • 18

3 Answers3

11

You need to provide a RemoveRoot property, this property sets the root to remove from the compress files path. (More info)

<ItemGroup>
  <ZipFiles Include="\Test\Web\**\*.*" >
    <Group>Release</Group>
  </ZipFiles>
</ItemGroup>

<MSBuild.ExtensionPack.Compression.Zip 
                        TaskAction="Create" 
                        CompressFiles="@(ZipFiles)" 
                        ZipFileName="$(WorkingDir)%(ZipFiles.Group).zip"
                        RemoveRoot="\Test\Web"/>
Michael Teper
  • 4,591
  • 2
  • 32
  • 49
Julien Hoarau
  • 48,964
  • 20
  • 128
  • 117
  • FWIW, using $(TargetDir) for both ZipFiles Include and RemoveRoot will target the build output files and create a flat ZIP – dlchambers Apr 20 '16 at 17:42
1

I believe you need to have a value for the RemoveRoot property.

Rick D
  • 346
  • 2
  • 11
0

Since, nobody answered early, I went ahead and used 7 Zip, Command line utility, to do that.

Manoj Talreja
  • 793
  • 3
  • 11
  • 18