diff --git a/README.md b/README.md
index e790ccd..d48219e 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ Useful MSBuild inline tasks and targets. Import the common.tasks and/or common.t
Usage examples
-Zip task:
+Zip task (ignore hierarchy):
```xml
@@ -18,6 +18,27 @@ Zip task:
OverwriteExistingFile="true" />
```
+Zip task (folders hierarchy maintained relative to InputBaseDirectory):
+
+
+
+
+
+
+
+ZipDir task (folders hierarchy maintained relative to InputBaseDirectory):
+
+
+
+
SafeGitClean:
diff --git a/common.tasks b/common.tasks
index 9439a45..5f46d38 100644
--- a/common.tasks
+++ b/common.tasks
@@ -4,6 +4,7 @@
+
@@ -13,11 +14,19 @@
Path.GetFullPath(f.ItemSpec)).Where(n => n.StartsWith(baseDir));
+
using (var archive = new ZipArchive(new FileStream(OutputFileName, fileMode), ZipArchiveMode.Create))
{
- foreach (var inputFileName in InputFileNames.Select(f => f.ItemSpec))
+ foreach (var inputFileName in filesToZip)
{
- var archiveEntry = archive.CreateEntry(Path.GetFileName(inputFileName));
+ var entryName = baseDir.Length == 0
+ ? Path.GetFileName(inputFileName)
+ : inputFileName.Substring(baseDir.Length + 1);
+
+
+ var archiveEntry = archive.CreateEntry(entryName);
using (var fs = new FileStream(inputFileName, FileMode.Open))
{
using (var zipStream = archiveEntry.Open())