Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Cake.Common.Tests/Unit/Tools/DotNet/Tool/DotNetToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
// Then
AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1).");
}

[Fact]
public void Should_Wrap_Command_In_Quotes()
{
// Given
var fixture = new DotNetToolFixture();
fixture.ProjectPath = "./tests/Cake.Common.Tests/";
fixture.Command = "C:\\example\\path with\\spaces";
fixture.Settings = new DotNetToolSettings();

// When
var result = fixture.Run();

// Then
Assert.Equal("\"C:\\example\\path with\\spaces\"", result.Args);
}
}
}
}
4 changes: 3 additions & 1 deletion src/Cake.Common/Tools/DotNet/Tool/DotNetToolRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ private ProcessArgumentBuilder GetArguments(string command, ProcessArgumentBuild
{
var builder = CreateArgumentBuilder(settings);

builder.Append(command);
// Appending quoted to cater for scenarios where the command passed is not a .NET CLI command,
// but the path of an application to run that contains whitespace
builder.AppendQuoted(command);

// Arguments
if (!arguments.IsNullOrEmpty())
Expand Down
Loading