Skip to content

Commit

Permalink
Merge branch 'hotfix/0.15.2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gep13 committed Jul 29, 2016
2 parents 1883823 + 529d052 commit c2ca4f7
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 121 deletions.
5 changes: 5 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 11 additions & 12 deletions src/Cake.Common.Tests/Fixtures/Tools/WiX/HeatFixture.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,7 +16,9 @@ internal sealed class HeatFixture : ToolFixture<HeatSettings>

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")
Expand All @@ -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;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.Common.Tests/Unit/Tools/WiX/CandleRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ public void Should_Add_Defines_To_Arguments_If_Provided()
// Given
var fixture = new CandleFixture();
fixture.Settings.Defines = new Dictionary<string, string>();
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]
Expand Down
24 changes: 18 additions & 6 deletions src/Cake.Common.Tests/Unit/Tools/WiX/HeatRunnerTests.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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);

}
}
}
}
18 changes: 1 addition & 17 deletions src/Cake.Common.Tests/Unit/Tools/WiX/WiXAliasTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<ICakeContext>();

// When
var result = Record.Exception(() => WiXAliases.WiXHeat(context, null, fixture.OutputFile));

// Then
Assert.IsArgumentNullException(result, "directoryPath");
}
}
}
}
2 changes: 1 addition & 1 deletion src/Cake.Common/Tools/WiX/CandleRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private ProcessArgumentBuilder GetArguments(IEnumerable<FilePath> 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);
Expand Down
88 changes: 36 additions & 52 deletions src/Cake.Common/Tools/WiX/Heat/HeatRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public HeatRunner(IFileSystem fileSystem, ICakeEnvironment environment, IProcess
/// </summary>
/// <param name="directoryPath">The directory path.</param>
/// <param name="outputFile">The output file.</param>
/// <param name="harvestType">The WiX harvest type.</param>
/// <param name="settings">The settings.</param>
public void Run(DirectoryPath directoryPath, FilePath outputFile, HeatSettings settings)
public void Run(DirectoryPath directoryPath, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings)
{
if (directoryPath == null)
{
Expand All @@ -60,16 +61,17 @@ 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));
}

/// <summary>
/// Runs the Wix Heat runner for the specified directory path.
/// </summary>
/// <param name="objectFiles">The object files.</param>
/// <param name="outputFile">The output file.</param>
/// <param name="harvestType">The WiX harvest type.</param>
/// <param name="settings">The settings.</param>
public void Run(IEnumerable<FilePath> objectFiles, FilePath outputFile, HeatSettings settings)
public void Run(IEnumerable<FilePath> objectFiles, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings)
{
if (objectFiles == null)
{
Expand All @@ -92,16 +94,17 @@ public void Run(IEnumerable<FilePath> 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));
}

/// <summary>
/// Runs the Wix Heat runner for the specified directory path.
/// </summary>
/// <param name="harvestTarget">The harvest target.</param>
/// <param name="outputFile">The output file.</param>
/// <param name="harvestType">The WiX harvest type.</param>
/// <param name="settings">The settings.</param>
public void Run(string harvestTarget, FilePath outputFile, HeatSettings settings)
public void Run(string harvestTarget, FilePath outputFile, WiXHarvestType harvestType, HeatSettings settings)
{
if (harvestTarget == null)
{
Expand All @@ -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<FilePath> objectFiles, FilePath outputFile, HeatSettings settings)
private ProcessArgumentBuilder GetArguments(IEnumerable<FilePath> 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))
Expand All @@ -156,22 +143,11 @@ private ProcessArgumentBuilder GetArguments(IEnumerable<FilePath> 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);
Expand All @@ -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);

Expand Down Expand Up @@ -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";
}
}

/// <summary>
/// Gets the name of the tool.
/// </summary>
Expand Down
9 changes: 0 additions & 9 deletions src/Cake.Common/Tools/WiX/Heat/HeatSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ namespace Cake.Common.Tools.WiX.Heat
/// </summary>
public sealed class HeatSettings : ToolSettings
{
/// <summary>
/// Gets or sets the type for WiX harvest.
/// Default is dir.
/// </summary>
/// <value>
/// The type of the harvest.
/// </value>
public WiXHarvestType? HarvestType { get; set; }

/// <summary>
/// Gets or sets the WiX extensions to use.
/// </summary>
Expand Down
Loading

0 comments on commit c2ca4f7

Please sign in to comment.