I'm looking at MSBuild.Extensionpack.Compression.Zip
to add a custom build step where I'd like to add some files to an existing .zip archive.
<ItemGroup>
<Files Include="$(MSBuildProjectDirectory)\SomeFolder\AnotherFolder\*.xml">
</Files>
</ItemGroup>
<Message Text="@(Files)"></Message>
<MSBuild.ExtensionPack.Compression.Zip TaskAction="AddFiles"
CompressFiles="@(Files)" ZipFileName="$(MyZipArchive)"/>
When running this, the files are indeed added to the zip archive, but not into the root. Instead it creates a file hierarchy that corresponds to the path of my project
Projects/MyProject/SomeFolder/AnotherFolder/myfile.xml
Any thoughts on how I can get the myfile.xml
inside the root of the .zip archive?
Sorry, I was getting to hasty. Just found the solution in the answer of this question.
The AddFiles action has an optional property RemoveRoot
. Here you have to specify the string of the root you want to remove.
Final solution looks like this.
<ItemGroup>
<Files Include="$(MSBuildProjectDirectory)\SomeFolder\AnotherFolder\*.xml">
</Files>
</ItemGroup>
<MSBuild.ExtensionPack.Compression.Zip TaskAction="AddFiles"
CompressFiles="@(Files)" ZipFileName="$(MyZipArchive)"
RemoveRoot=$(MSBuildProjectDirectory)\SomeFolder\AnotherFolder />