diff --git a/ReleaseNotes.md b/ReleaseNotes.md index dd16fd5fb3..a19d7764d4 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,8 @@ +### New on 0.15.2 (Released 2016/07/29) + +* Ensured that WiX candle definitions are enclosed in quotes +* Corrected issue with WixHeat HarvestType Out parameter + ### New on 0.15.1 (Released 2016/07/28) * Corrected Issues found with 0.15.0 AppVeyor updates diff --git a/src/Cake.Common.Tests/Fixtures/Tools/WiX/HeatFixture.cs b/src/Cake.Common.Tests/Fixtures/Tools/WiX/HeatFixture.cs index f8aeb0a5f3..7c9bc51061 100644 --- a/src/Cake.Common.Tests/Fixtures/Tools/WiX/HeatFixture.cs +++ b/src/Cake.Common.Tests/Fixtures/Tools/WiX/HeatFixture.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - -using System; using System.Collections.Generic; using Cake.Common.Tools.WiX.Heat; using Cake.Core.IO; @@ -18,7 +16,9 @@ internal sealed class HeatFixture : ToolFixture public FilePath OutputFile { get; set; } - public string HarvestType { get; set; } + public string HarvestTarget { get; set; } + + public WiXHarvestType HarvestType { get; set; } public HeatFixture() : base("heat.exe") @@ -28,32 +28,31 @@ public HeatFixture() ObjectFiles.Add(new FilePath("Cake.dll")); OutputFile = new FilePath("cake.wxs"); Settings = new HeatSettings(); - Settings.HarvestType = WiXHarvestType.Dir; - HarvestType = "Default Web Site"; + HarvestType = WiXHarvestType.Dir; + HarvestTarget = "Default Web Site"; } protected override void RunTool() { var tool = new HeatRunner(FileSystem, Environment, ProcessRunner, Tools); - switch (Settings.HarvestType) + switch (HarvestType) { case WiXHarvestType.Dir: - tool.Run(DirectoryPath, OutputFile, Settings); + tool.Run(DirectoryPath, OutputFile, HarvestType, Settings); break; case WiXHarvestType.File: case WiXHarvestType.Project: case WiXHarvestType.Reg: - tool.Run(ObjectFiles, OutputFile, Settings); + tool.Run(ObjectFiles, OutputFile, HarvestType, Settings); break; case WiXHarvestType.Website: case WiXHarvestType.Perf: - tool.Run(HarvestType, OutputFile, Settings); - break; - case null: + tool.Run(HarvestTarget, OutputFile, HarvestType, Settings); break; default: - throw new ArgumentOutOfRangeException(); + tool.Run(DirectoryPath, OutputFile, HarvestType, Settings); + break; } } } diff --git a/src/Cake.Common.Tests/Unit/Tools/WiX/CandleRunnerTests.cs b/src/Cake.Common.Tests/Unit/Tools/WiX/CandleRunnerTests.cs index 87abd83f13..e07c3566c6 100644 --- a/src/Cake.Common.Tests/Unit/Tools/WiX/CandleRunnerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/WiX/CandleRunnerTests.cs @@ -221,13 +221,13 @@ public void Should_Add_Defines_To_Arguments_If_Provided() // Given var fixture = new CandleFixture(); fixture.Settings.Defines = new Dictionary(); - fixture.Settings.Defines.Add("Foo", "Bar"); + fixture.Settings.Defines.Add("Foo", "Foo Bar"); // When var result = fixture.Run(); // Then - Assert.Equal("-dFoo=Bar \"/Working/Test.wxs\"", result.Args); + Assert.Equal("-dFoo=\"Foo Bar\" \"/Working/Test.wxs\"", result.Args); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/WiX/HeatRunnerTests.cs b/src/Cake.Common.Tests/Unit/Tools/WiX/HeatRunnerTests.cs index ea590d91ec..1185f5c73d 100644 --- a/src/Cake.Common.Tests/Unit/Tools/WiX/HeatRunnerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/WiX/HeatRunnerTests.cs @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - using System; using Cake.Common.Tests.Fixtures.Tools.WiX; using Cake.Common.Tools.WiX.Heat; using Cake.Core; -using Cake.Core.IO; using Cake.Testing; using Cake.Testing.Xunit; using Xunit; @@ -187,7 +185,7 @@ public void Should_Add_File_Harvest_Type_If_Provided() { // Given var fixture = new HeatFixture(); - fixture.Settings.HarvestType = WiXHarvestType.File; + fixture.HarvestType = WiXHarvestType.File; // When var result = fixture.Run(); @@ -201,7 +199,7 @@ public void Should_Add_Website_Harvest_Type_If_Provided() { // Given var fixture = new HeatFixture(); - fixture.Settings.HarvestType = WiXHarvestType.Website; + fixture.HarvestType = WiXHarvestType.Website; // When var result = fixture.Run(); @@ -215,8 +213,8 @@ public void Should_Add_Performance_Harvest_Type_If_Provided() { // Given var fixture = new HeatFixture(); - fixture.Settings.HarvestType = WiXHarvestType.Perf; - fixture.HarvestType = "Cake Category"; + fixture.HarvestType = WiXHarvestType.Perf; + fixture.HarvestTarget = "Cake Category"; // When var result = fixture.Run(); @@ -714,6 +712,20 @@ public void Should_Add_Generate_Binder_Variables_To_Arguments_If_Provided() // Then Assert.Equal("dir \"/Working/src/Cake\" -wixvar -out \"/Working/cake.wxs\"", result.Args); } + + [Fact] + public void Should_Default_To_Directory_Harvest_Type() + { + // Given + var fixture = new HeatFixture(); + + // When + var result = fixture.Run(); + + // Then + Assert.Equal("dir \"/Working/src/Cake\" -out \"/Working/cake.wxs\"", result.Args); + + } } } } \ No newline at end of file diff --git a/src/Cake.Common.Tests/Unit/Tools/WiX/WiXAliasTests.cs b/src/Cake.Common.Tests/Unit/Tools/WiX/WiXAliasTests.cs index 72f03c1e9a..d6fd92f5ba 100644 --- a/src/Cake.Common.Tests/Unit/Tools/WiX/WiXAliasTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/WiX/WiXAliasTests.cs @@ -4,8 +4,6 @@ using Cake.Common.Tests.Fixtures.Tools.WiX; using Cake.Common.Tools.WiX; -using Cake.Core; -using NSubstitute; using Xunit; namespace Cake.Common.Tests.Unit.Tools.WiX @@ -21,25 +19,11 @@ public void Should_Throw_If_Context_Is_Null() var fixture = new HeatFixture(); // When - var result = Record.Exception(() => WiXAliases.WiXHeat(null, fixture.DirectoryPath, fixture.OutputFile)); + var result = Record.Exception(() => WiXAliases.WiXHeat(null, fixture.DirectoryPath, fixture.OutputFile, fixture.HarvestType)); // Then Assert.IsArgumentNullException(result, "context"); } - - [Fact] - public void Should_Throw_If_Directory_Path_Is_Null() - { - // Given - var fixture = new HeatFixture(); - var context = Substitute.For(); - - // When - var result = Record.Exception(() => WiXAliases.WiXHeat(context, null, fixture.OutputFile)); - - // Then - Assert.IsArgumentNullException(result, "directoryPath"); - } } } } \ No newline at end of file diff --git a/src/Cake.Common/Tools/WiX/CandleRunner.cs b/src/Cake.Common/Tools/WiX/CandleRunner.cs index 48bfff5665..8c867c853d 100644 --- a/src/Cake.Common/Tools/WiX/CandleRunner.cs +++ b/src/Cake.Common/Tools/WiX/CandleRunner.cs @@ -79,7 +79,7 @@ private ProcessArgumentBuilder GetArguments(IEnumerable sourceFiles, C // Add defines if (settings.Defines != null && settings.Defines.Any()) { - var defines = settings.Defines.Select(define => string.Format(CultureInfo.InvariantCulture, "-d{0}={1}", define.Key, define.Value)); + var defines = settings.Defines.Select(define => string.Format(CultureInfo.InvariantCulture, "-d{0}=\"{1}\"", define.Key, define.Value)); foreach (var define in defines) { builder.Append(define); diff --git a/src/Cake.Common/Tools/WiX/Heat/HeatRunner.cs b/src/Cake.Common/Tools/WiX/Heat/HeatRunner.cs index 61d8e5479b..805615c834 100644 --- a/src/Cake.Common/Tools/WiX/Heat/HeatRunner.cs +++ b/src/Cake.Common/Tools/WiX/Heat/HeatRunner.cs @@ -42,8 +42,9 @@ public HeatRunner(IFileSystem fileSystem, ICakeEnvironment environment, IProcess /// /// The directory path. /// The output file. + /// The WiX harvest type. /// The settings. - public void Run(DirectoryPath directoryPath, FilePath outputFile, HeatSettings settings) + public void Run(DirectoryPath directoryPath, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings) { if (directoryPath == null) { @@ -60,7 +61,7 @@ public void Run(DirectoryPath directoryPath, FilePath outputFile, HeatSettings s throw new ArgumentNullException("settings"); } - Run(settings, GetArguments(directoryPath, outputFile, settings)); + Run(settings, GetArguments(directoryPath, outputFile, harvestType, settings)); } /// @@ -68,8 +69,9 @@ public void Run(DirectoryPath directoryPath, FilePath outputFile, HeatSettings s /// /// The object files. /// The output file. + /// The WiX harvest type. /// The settings. - public void Run(IEnumerable objectFiles, FilePath outputFile, HeatSettings settings) + public void Run(IEnumerable objectFiles, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings) { if (objectFiles == null) { @@ -92,7 +94,7 @@ public void Run(IEnumerable objectFiles, FilePath outputFile, HeatSett throw new ArgumentException("No object files provided.", "objectFiles"); } - Run(settings, GetArguments(objectFilesArray, outputFile, settings)); + Run(settings, GetArguments(objectFilesArray, outputFile, harvestType, settings)); } /// @@ -100,8 +102,9 @@ public void Run(IEnumerable objectFiles, FilePath outputFile, HeatSett /// /// The harvest target. /// The output file. + /// The WiX harvest type. /// The settings. - public void Run(string harvestTarget, FilePath outputFile, HeatSettings settings) + public void Run(string harvestTarget, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings) { if (harvestTarget == null) { @@ -118,30 +121,14 @@ public void Run(string harvestTarget, FilePath outputFile, HeatSettings settings throw new ArgumentNullException("settings"); } - Run(settings, GetArguments(harvestTarget, outputFile, settings)); + Run(settings, GetArguments(harvestTarget, outputFile, harvestType, settings)); } - private ProcessArgumentBuilder GetArguments(IEnumerable objectFiles, FilePath outputFile, HeatSettings settings) + private ProcessArgumentBuilder GetArguments(IEnumerable objectFiles, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings) { var builder = new ProcessArgumentBuilder(); - if (settings.HarvestType != null) - { - switch (settings.HarvestType) - { - case WiXHarvestType.File: - builder.Append("file"); - break; - case WiXHarvestType.Project: - builder.Append("project"); - break; - case WiXHarvestType.Reg: - builder.Append("reg"); - break; - default: - throw new ArgumentException("Incorrect harvest type for input.", "objectFiles"); - } - } + builder.Append(GetHarvestType(harvestType)); // Object files foreach (var objectFile in objectFiles.Select(file => file.MakeAbsolute(_environment).FullPath)) @@ -156,22 +143,11 @@ private ProcessArgumentBuilder GetArguments(IEnumerable objectFiles, F return builder; } - private ProcessArgumentBuilder GetArguments(DirectoryPath directoryPath, FilePath outputFile, HeatSettings settings) + private ProcessArgumentBuilder GetArguments(DirectoryPath directoryPath, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings) { var builder = new ProcessArgumentBuilder(); - if (settings.HarvestType != null) - { - switch (settings.HarvestType) - { - case WiXHarvestType.Dir: - builder.Append("dir"); - break; - default: - throw new ArgumentException("Incorrect harvest type for input.", "directoryPath"); - } - } - + builder.Append(GetHarvestType(harvestType)); builder.AppendQuoted(directoryPath.MakeAbsolute(_environment).FullPath); var args = GetArguments(outputFile, settings); @@ -181,24 +157,11 @@ private ProcessArgumentBuilder GetArguments(DirectoryPath directoryPath, FilePat return builder; } - private ProcessArgumentBuilder GetArguments(string harvestTarget, FilePath outputFile, HeatSettings settings) + private ProcessArgumentBuilder GetArguments(string harvestTarget, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings) { var builder = new ProcessArgumentBuilder(); - if (settings.HarvestType != null) - { - switch (settings.HarvestType) - { - case WiXHarvestType.Perf: - builder.Append("perf"); - break; - case WiXHarvestType.Website: - builder.Append("website"); - break; - default: - throw new ArgumentException("Incorrect harvest type for input.", "harvestTarget"); - } - } + builder.Append(GetHarvestType(harvestType)); builder.AppendQuoted(harvestTarget); @@ -432,6 +395,27 @@ private ProcessArgumentBuilder GetArguments(FilePath outputFile, HeatSettings se return builder; } + private string GetHarvestType(WiXHarvestType harvestType) + { + switch (harvestType) + { + case WiXHarvestType.Dir: + return "dir"; + case WiXHarvestType.File: + return "file"; + case WiXHarvestType.Project: + return "project"; + case WiXHarvestType.Reg: + return "reg"; + case WiXHarvestType.Perf: + return "perf"; + case WiXHarvestType.Website: + return "website"; + default: + return "dir"; + } + } + /// /// Gets the name of the tool. /// diff --git a/src/Cake.Common/Tools/WiX/Heat/HeatSettings.cs b/src/Cake.Common/Tools/WiX/Heat/HeatSettings.cs index 1c0a217c94..fc00c0fb60 100644 --- a/src/Cake.Common/Tools/WiX/Heat/HeatSettings.cs +++ b/src/Cake.Common/Tools/WiX/Heat/HeatSettings.cs @@ -13,15 +13,6 @@ namespace Cake.Common.Tools.WiX.Heat /// public sealed class HeatSettings : ToolSettings { - /// - /// Gets or sets the type for WiX harvest. - /// Default is dir. - /// - /// - /// The type of the harvest. - /// - public WiXHarvestType? HarvestType { get; set; } - /// /// Gets or sets the WiX extensions to use. /// diff --git a/src/Cake.Common/Tools/WiX/WiXAliases.cs b/src/Cake.Common/Tools/WiX/WiXAliases.cs index c3e84c9f8b..c175917f3a 100644 --- a/src/Cake.Common/Tools/WiX/WiXAliases.cs +++ b/src/Cake.Common/Tools/WiX/WiXAliases.cs @@ -155,18 +155,19 @@ public static void WiXLight(this ICakeContext context, IEnumerable obj /// /// /// - /// var harvestDirectory = Directory("./src"); - /// var filePath = new FilePath("cake.wxs"); - /// WiXHeat(harvestDirectory, filePath); + /// DirectoryPath harvestDirectory = Directory("./src"); + /// var filePath = new FilePath("Wix.Directory.wxs"); + /// WiXHeat(harvestDirectory, filePath, WiXHarvestType.Dir); /// /// /// The context. /// The object files. /// The output file. + /// The WiX harvest type. [CakeMethodAlias] [CakeAliasCategory("Heat")] [CakeNamespaceImport("Cake.Common.Tools.WiX.Heat")] - public static void WiXHeat(this ICakeContext context, DirectoryPath directoryPath, FilePath outputFile) + public static void WiXHeat(this ICakeContext context, DirectoryPath directoryPath, FilePath outputFile, WiXHarvestType harvestType) { if (context == null) { @@ -174,7 +175,7 @@ public static void WiXHeat(this ICakeContext context, DirectoryPath directoryPat } var runner = new HeatRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - runner.Run(directoryPath, outputFile, new HeatSettings()); + runner.Run(directoryPath, outputFile, harvestType, new HeatSettings()); } /// @@ -182,19 +183,21 @@ public static void WiXHeat(this ICakeContext context, DirectoryPath directoryPat /// /// /// - /// var harvestDirectory = Directory("./src"); - /// var filePath = new FilePath("cake.wxs"); - /// WiXHeat(harvestDirectory, filePath, new HeatSettings { HarvestType = WiXHarvestType.Dir }); + /// DirectoryPath harvestDirectory = Directory("./src"); + /// var filePath = File("Wix.Directory.wxs"); + /// Information(MakeAbsolute(harvestDirectory).FullPath); + /// WiXHeat(harvestDirectory, filePath, WiXHarvestType.Dir, new HeatSettings { NoLogo = true }); /// /// /// The context. /// The directory path. /// The output file. + /// The WiX harvest type. /// The settings. [CakeMethodAlias] [CakeAliasCategory("Heat")] [CakeNamespaceImport("Cake.Common.Tools.WiX.Heat")] - public static void WiXHeat(this ICakeContext context, DirectoryPath directoryPath, FilePath outputFile, HeatSettings settings) + public static void WiXHeat(this ICakeContext context, DirectoryPath directoryPath, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings) { if (context == null) { @@ -202,7 +205,7 @@ public static void WiXHeat(this ICakeContext context, DirectoryPath directoryPat } var runner = new HeatRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - runner.Run(directoryPath, outputFile, settings ?? new HeatSettings()); + runner.Run(directoryPath, outputFile, harvestType, settings ?? new HeatSettings()); } /// @@ -210,19 +213,75 @@ public static void WiXHeat(this ICakeContext context, DirectoryPath directoryPat /// /// /// - /// var harvestFiles = GetFiles(".src/website/bin/website.dll"); - /// var filePath = File("cake.wxs"); - /// WiXHeat(harvestFiles, filePath, new HeatSettings { HarvestType = WiXHarvestType.File }); + /// var harvestFile = File("./tools/Cake/Cake.Core.dll"); + /// var filePath = File("Wix.File.wxs"); + /// WiXHeat(harvestFile, filePath, WiXHarvestType.File); /// /// /// The context. /// The object files. /// The output file. + /// The WiX harvest type. + [CakeMethodAlias] + [CakeAliasCategory("Heat")] + [CakeNamespaceImport("Cake.Common.Tools.WiX.Heat")] + public static void WiXHeat(this ICakeContext context, IEnumerable objectFiles, FilePath outputFile, WiXHarvestType harvestType) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + + var runner = new HeatRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); + runner.Run(objectFiles, outputFile, harvestType, new HeatSettings()); + } + + /// + /// Harvests from the desired files. + /// + /// + /// + /// var harvestFiles = File("./tools/Cake/*.dll"); + /// var filePath = File("Wix.File.wxs"); + /// WiXHeat(harvestFiles, filePath, WiXHarvestType.File, new HeatSettings { NoLogo = true }); + /// + /// + /// The context. + /// The object files. + /// The output file. + /// The WiX harvest type. /// The settings. [CakeMethodAlias] [CakeAliasCategory("Heat")] [CakeNamespaceImport("Cake.Common.Tools.WiX.Heat")] - public static void WiXHeat(this ICakeContext context, IEnumerable objectFiles, FilePath outputFile, HeatSettings settings) + public static void WiXHeat(this ICakeContext context, IEnumerable objectFiles, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + + var runner = new HeatRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); + runner.Run(objectFiles, outputFile, harvestType, settings ?? new HeatSettings()); + } + + /// + /// Harvests files for a website or performance. + /// + /// + /// + /// var filePath = File("Wix.Website.wxs"); + /// WiXHeat("Default Web Site", filePath, WiXHarvestType.Website); + /// + /// + /// The context. + /// The harvest target. + /// The output file. + /// The WiX harvest type. + [CakeMethodAlias] + [CakeAliasCategory("Heat")] + [CakeNamespaceImport("Cake.Common.Tools.WiX.Heat")] + public static void WiXHeat(this ICakeContext context, string harvestTarget, FilePath outputFile, WiXHarvestType harvestType) { if (context == null) { @@ -230,7 +289,7 @@ public static void WiXHeat(this ICakeContext context, IEnumerable obje } var runner = new HeatRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - runner.Run(objectFiles, outputFile, settings ?? new HeatSettings()); + runner.Run(harvestTarget, outputFile, harvestType, new HeatSettings()); } /// @@ -238,18 +297,19 @@ public static void WiXHeat(this ICakeContext context, IEnumerable obje /// /// /// - /// var filePath = File("cake.wxs"); - /// WiXHeat("Default Web Site", filePath, new HeatSettings { HarvestType = WiXHarvestType.Website }); + /// var filePath = File("Wix.Website.wxs"); + /// WiXHeat("Default Web Site", filePath, WiXHarvestType.Website, new HeatSettings { NoLogo = true }); /// /// /// The context. /// The harvest target. /// The output file. + /// The WiX harvest type. /// The settings. [CakeMethodAlias] [CakeAliasCategory("Heat")] [CakeNamespaceImport("Cake.Common.Tools.WiX.Heat")] - public static void WiXHeat(this ICakeContext context, string harvestTarget, FilePath outputFile, HeatSettings settings) + public static void WiXHeat(this ICakeContext context, string harvestTarget, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings) { if (context == null) { @@ -257,7 +317,7 @@ public static void WiXHeat(this ICakeContext context, string harvestTarget, File } var runner = new HeatRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - runner.Run(harvestTarget, outputFile, settings ?? new HeatSettings()); + runner.Run(harvestTarget, outputFile, harvestType, settings ?? new HeatSettings()); } } } \ No newline at end of file diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index 4866c4ad62..0c02399b95 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -10,7 +10,7 @@ using System.Reflection; [assembly: AssemblyProduct("Cake")] -[assembly: AssemblyVersion("0.15.1.0")] -[assembly: AssemblyFileVersion("0.15.1.0")] -[assembly: AssemblyInformationalVersion("0.15.1-beta.1+2.Branch.hotfix/0.15.1.Sha.2a4757b270f7946122ba6622e3d2e72b2b2808a7")] +[assembly: AssemblyVersion("0.15.2.0")] +[assembly: AssemblyFileVersion("0.15.2.0")] +[assembly: AssemblyInformationalVersion("0.15.2-beta.1+2.Branch.hotfix/0.15.2.Sha.88a61b352eb49e97390124d6144cdca38ef40645")] [assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")] \ No newline at end of file