From 0fffcfdf1bcdba39cb6c12a1c32801b61dbc6c68 Mon Sep 17 00:00:00 2001 From: Jason Pierce Date: Mon, 10 Jun 2013 06:20:09 -0500 Subject: [PATCH 1/2] Added RootDirectory option to Zip task --- Source/MSBuild.Community.Tasks/Zip.cs | 34 ++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/Source/MSBuild.Community.Tasks/Zip.cs b/Source/MSBuild.Community.Tasks/Zip.cs index 9cbc602b..5b085058 100644 --- a/Source/MSBuild.Community.Tasks/Zip.cs +++ b/Source/MSBuild.Community.Tasks/Zip.cs @@ -65,6 +65,17 @@ namespace MSBuild.Community.Tasks /// ZipFileName="D:\svn\repo.zip" /> /// /// ]]> + /// Create a zip file using a root directory. + /// + /// + /// + /// + /// + /// + /// ]]> /// public class Zip : Task { @@ -125,11 +136,19 @@ public Zip() /// /// The working directory. /// - /// The working directory is the base of the zip file. /// All files will be made relative from the working directory. /// public string WorkingDirectory { get; set; } + /// + /// Gets or sets the root directory for the archive. + /// + /// The root directory. + /// + /// The root directory is the base of the archive. + /// + public string RootDirectory { get; set; } + /// /// Gets or sets the password. /// @@ -249,7 +268,7 @@ private bool ZipFiles() // maybe a directory if (Directory.Exists(name)) { - var directoryEntry = zip.AddDirectory(name, directoryPathInArchive); + var directoryEntry = zip.AddDirectory(name, GetArchivePath(RootDirectory, directoryPathInArchive)); if (!Quiet) Log.LogMessage(Resources.ZipAdded, directoryEntry.FileName); @@ -265,7 +284,7 @@ private bool ZipFiles() && Path.GetFileName(directoryPathInArchive) == Path.GetFileName(name)) directoryPathInArchive = Path.GetDirectoryName(directoryPathInArchive); - var entry = zip.AddFile(name, directoryPathInArchive); + var entry = zip.AddFile(name, GetArchivePath(RootDirectory, directoryPathInArchive)); if (!Quiet) Log.LogMessage(Resources.ZipAdded, entry.FileName); } @@ -283,6 +302,15 @@ private bool ZipFiles() return true; } + private static string GetArchivePath(string rootDirectory, string directoryPathInArchive) + { + return String.IsNullOrEmpty(rootDirectory) + ? directoryPathInArchive + : String.IsNullOrEmpty(directoryPathInArchive) + ? rootDirectory + : Path.Combine(rootDirectory, directoryPathInArchive); + } + private static string GetPath(string originalPath, string rootDirectory) { var relativePath = new List(); From efc764d7e0237806094ad9f50850eed01e1327a4 Mon Sep 17 00:00:00 2001 From: Jason Pierce Date: Mon, 9 Sep 2024 13:16:10 -0400 Subject: [PATCH 2/2] Add archived message to README.md --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index ed56cef9..da282fa6 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,7 @@ +> # Archived Repository 🚨 +> **This project is no longer maintained and has been archived. No further issues, PRs, or updates will be made.** +--- + #MSBuild Community Tasks The MSBuild Community Tasks Project is an open source project for MSBuild tasks.