From f150d576caed5413b6c937081616922fefadcbc4 Mon Sep 17 00:00:00 2001 From: jricke Date: Wed, 25 Nov 2015 16:26:29 -0600 Subject: [PATCH 1/2] Adding self extracting archive options to Zip task. Changing DotNetZip NuGet package to full version to support self extracting archives. --- .../MSBuild.Community.Tasks.Tests.csproj | 437 ++++++------- .../packages.config | 10 +- .../MSBuild.Community.Tasks.csproj | 594 +++++++++--------- Source/MSBuild.Community.Tasks/Zip.cs | 162 ++++- .../MSBuild.Community.Tasks/packages.config | 6 +- 5 files changed, 685 insertions(+), 524 deletions(-) diff --git a/Source/MSBuild.Community.Tasks.Tests/MSBuild.Community.Tasks.Tests.csproj b/Source/MSBuild.Community.Tasks.Tests/MSBuild.Community.Tasks.Tests.csproj index fcf23aed..aba84240 100644 --- a/Source/MSBuild.Community.Tasks.Tests/MSBuild.Community.Tasks.Tests.csproj +++ b/Source/MSBuild.Community.Tasks.Tests/MSBuild.Community.Tasks.Tests.csproj @@ -1,219 +1,220 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {5AC1D006-CA56-4BE1-8250-DBEABBEA0725} - Library - MSBuild.Community.Tasks.Tests - MSBuild.Community.Tasks.Tests - 4 - false - - - 3.5 - - - ..\MSBuild.Community.Tasks\MSBuild.Community.Tasks.snk - v4.0 - ..\ - true - - - - true - full - false - .\bin\Debug\ - DEBUG;TRACE - true - AllRules.ruleset - false - - - false - true - .\bin\Release\ - TRACE - true - true - AllRules.ruleset - false - - - - ..\packages\DotNetZip.Reduced.1.9.1.8\lib\net20\Ionic.Zip.Reduced.dll - - - - - - False - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - - - False - ..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {F88A60A8-564C-4E70-92DC-E92DBB897641} - MSBuild.Community.Tasks - True - - - - - - - Form - - - - PreserveNewest - - - MSBuild.Community.Tasks.snk - - - - - - - - - - Designer - - - - - - - - - - - - - - PreserveNewest - - - - PreserveNewest - - - - - PreserveNewest - - - - - - - - - - + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {5AC1D006-CA56-4BE1-8250-DBEABBEA0725} + Library + MSBuild.Community.Tasks.Tests + MSBuild.Community.Tasks.Tests + 4 + false + + + 3.5 + + + ..\MSBuild.Community.Tasks\MSBuild.Community.Tasks.snk + v4.0 + ..\ + true + + + + true + full + false + .\bin\Debug\ + DEBUG;TRACE + true + AllRules.ruleset + false + + + false + true + .\bin\Release\ + TRACE + true + true + AllRules.ruleset + false + + + + ..\packages\DotNetZip.1.9.7\lib\net20\Ionic.Zip.dll + True + + + + + + False + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + + False + ..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Code + + + Code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {F88A60A8-564C-4E70-92DC-E92DBB897641} + MSBuild.Community.Tasks + True + + + + + + + Form + + + + PreserveNewest + + + MSBuild.Community.Tasks.snk + + + + + + + + + + Designer + + + + + + + + + + + + + + PreserveNewest + + + + PreserveNewest + + + + + PreserveNewest + + + + + + + + + + \ No newline at end of file diff --git a/Source/MSBuild.Community.Tasks.Tests/packages.config b/Source/MSBuild.Community.Tasks.Tests/packages.config index 589ef756..d0910c59 100644 --- a/Source/MSBuild.Community.Tasks.Tests/packages.config +++ b/Source/MSBuild.Community.Tasks.Tests/packages.config @@ -1,6 +1,6 @@ - - - - - + + + + + \ No newline at end of file diff --git a/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.csproj b/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.csproj index 3f6b8721..f8f70b79 100644 --- a/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.csproj +++ b/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.csproj @@ -1,303 +1,305 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {F88A60A8-564C-4E70-92DC-E92DBB897641} - Library - Properties - MSBuild.Community.Tasks - MSBuild.Community.Tasks - false - MSBuild.Community.Tasks.snk - - - 3.5 - - - v4.0 - ..\ - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\MSBuild.Community.Tasks.xml - false - true - AllRules.ruleset - false - - - pdbonly - true - ..\..\Build\ - - - prompt - 4 - ..\..\Build\MSBuild.Community.Tasks.xml - false - AllRules.ruleset - false - - - - ..\packages\DotNetZip.Reduced.1.9.1.8\lib\net20\Ionic.Zip.Reduced.dll - - - - - - - - - - - - - - GlobalAssemblyInfo.cs - - - - - - - - - - - - - - - - - Code - - - Code - - - - Code - - - Code - - - Code - - - - Code - - - - Code - - - - - Code - - - Code - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - Code - - - - Code - - - Code - - - - Code - - - Code - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - Always - - - - - - Designer - ResXFileCodeGenerator - Resources.Designer.cs - - - - - - - - - - xcopy "$(TargetDir)*.*" "C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\" /Y - + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {F88A60A8-564C-4E70-92DC-E92DBB897641} + Library + Properties + MSBuild.Community.Tasks + MSBuild.Community.Tasks + false + MSBuild.Community.Tasks.snk + + + 3.5 + + + v4.0 + ..\ + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + bin\Debug\MSBuild.Community.Tasks.xml + false + true + AllRules.ruleset + false + + + pdbonly + true + ..\..\Build\ + + + prompt + 4 + ..\..\Build\MSBuild.Community.Tasks.xml + false + AllRules.ruleset + false + + + + ..\packages\DotNetZip.1.9.7\lib\net20\Ionic.Zip.dll + True + + + + + + + + + + + + + + GlobalAssemblyInfo.cs + + + + + + + + + + + + + + + + + Code + + + Code + + + + Code + + + Code + + + Code + + + + Code + + + + Code + + + + + Code + + + Code + + + + Code + + + + + + + + + + + + + + + + + + + + + + + + + + + + Code + + + Code + + + + Code + + + Code + + + + Code + + + Code + + + + + Code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + Always + + + + + + Designer + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + + + + + + + + --> \ No newline at end of file diff --git a/Source/MSBuild.Community.Tasks/Zip.cs b/Source/MSBuild.Community.Tasks/Zip.cs index e827aa32..2806d18c 100644 --- a/Source/MSBuild.Community.Tasks/Zip.cs +++ b/Source/MSBuild.Community.Tasks/Zip.cs @@ -182,7 +182,133 @@ public bool MinimalLogging /// /// false to output a message for every file added to a zip; otherwise, true. [DefaultValue(false)] - public bool Quiet { get; set; } + public bool Quiet { get; set; } + + /// + /// Gets or sets a value indicating whether the output is self extracting. Defaults to false. + /// + /// true to output a self extracting archive; otherwise, false. + [DefaultValue(false)] + public bool SelfExtracting { get; set; } + + /// + /// Gets or sets the copyright. + /// + /// + /// The copyright. + /// + public string Copyright { get; set; } + + /// + /// Gets or sets the default extract directory. + /// + /// + /// The default extract directory. + /// + public string DefaultExtractDirectory { get; set; } + + /// + /// Gets or sets the description. + /// + /// + /// The description. + /// + public string Description { get; set; } + + /// + /// Gets or sets the file version. + /// + /// + /// The file version. + /// + public string FileVersion { get; set; } + + /// + /// Gets or sets a value indicating whether console self extractor or windows forms. + /// + /// + /// true if console self extractor; otherwise, false for windows forms extractor. + /// + [DefaultValue(false)] + public bool ConsoleSelfExtractor { get; set; } + + /// + /// Gets or sets the icon file. + /// + /// + /// The icon file. + /// + public string IconFile { get; set; } + + /// + /// Gets or sets the post extract command line. + /// + /// + /// The post extract command line. + /// + public string PostExtractCommandLine { get; set; } + + /// + /// Gets or sets the name of the product. + /// + /// + /// The name of the product. + /// + public string ProductName { get; set; } + + /// + /// Gets or sets the product version. + /// + /// + /// The product version. + /// + public string ProductVersion { get; set; } + + /// + /// Gets or sets a value indicating whether quiet extraction for console self extracting archives. + /// + /// + /// true if quiet extraction for console self extracting archives; otherwise, false. + /// + [DefaultValue(false)] + public bool QuietExtraction { get; set; } + + /// + /// Gets or sets a value indicating whether remove unpacked files after execute. + /// + /// + /// true if remove unpacked files after execute; otherwise, false. + /// + [DefaultValue(false)] + public bool RemoveUnpackedFilesAfterExecute { get; set; } + + /// + /// Gets or sets the self extracting archive window title. + /// + /// + /// The self extracting archive window title. + /// + public string SelfExtractingArchiveWindowTitle { get; set; } + + /// + /// Gets or sets the additional compiler switches. + /// + /// + /// The additional compiler switches. + /// + public string AdditionalCompilerSwitches { get; set; } + + /// + /// Gets or sets the extract existing file action. + /// 0 = Throw + /// 1 = OverwriteSilently + /// 2 = DoNotOverwrite + /// + /// + /// The extract existing file action. + /// + [DefaultValue(0)] + public int ExtractExistingFileAction { get; set; } #endregion Input Parameters @@ -282,9 +408,41 @@ private bool ZipFiles() var entry = zip.AddFile(name, directoryPathInArchive); if (!Quiet) Log.LogMessage(Resources.ZipAdded, entry.FileName); + } + + if (SelfExtracting) + { + var options = new SelfExtractorSaveOptions + { + AdditionalCompilerSwitches = AdditionalCompilerSwitches, + Copyright = Copyright, + DefaultExtractDirectory = DefaultExtractDirectory, + Description = Description, + ExtractExistingFile = (ExtractExistingFileAction) ExtractExistingFileAction, + Flavor = ConsoleSelfExtractor + ? SelfExtractorFlavor.ConsoleApplication + : SelfExtractorFlavor.WinFormsApplication, + IconFile = IconFile, + PostExtractCommandLine = PostExtractCommandLine, + ProductName = ProductName, + ProductVersion = ProductVersion, + Quiet = QuietExtraction, + RemoveUnpackedFilesAfterExecute = RemoveUnpackedFilesAfterExecute, + SfxExeWindowTitle = SelfExtractingArchiveWindowTitle + }; + + if (!string.IsNullOrWhiteSpace(FileVersion)) + { + options.FileVersion = new System.Version(FileVersion); + } + + zip.SaveSelfExtractor(ZipFileName, options); + } + else + { + zip.Save(ZipFileName); } - zip.Save(ZipFileName); Log.LogMessage(Resources.ZipSuccessfully, ZipFileName); } } diff --git a/Source/MSBuild.Community.Tasks/packages.config b/Source/MSBuild.Community.Tasks/packages.config index e8f3bfd2..4f530311 100644 --- a/Source/MSBuild.Community.Tasks/packages.config +++ b/Source/MSBuild.Community.Tasks/packages.config @@ -1,4 +1,4 @@ - - - + + + \ No newline at end of file From 5d460ec652a65465f8b6574f654914b85c0a12c2 Mon Sep 17 00:00:00 2001 From: jricke Date: Wed, 25 Nov 2015 16:45:32 -0600 Subject: [PATCH 2/2] fixing build for new DotNetZip library --- Master.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Master.proj b/Master.proj index 3bc7bf84..7659eb6d 100644 --- a/Master.proj +++ b/Master.proj @@ -88,7 +88,7 @@ DestinationFiles="$(BuildFolder)\MSBuild.Temp.dll" /> -