Skip to content

Commit 7f89aaf

Browse files
authored
Merge pull request #4537 from antonysmith-mandogroup/feature/GH-4286
GH4286: Update DotNetToolRunner to append command using quotes
2 parents 6476d17 + 0edec6f commit 7f89aaf

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/Cake.Common.Tests/Unit/Tools/DotNet/Tool/DotNetToolTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
9696
// Then
9797
AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1).");
9898
}
99+
100+
[Fact]
101+
public void Should_Wrap_Command_In_Quotes()
102+
{
103+
// Given
104+
var fixture = new DotNetToolFixture();
105+
fixture.ProjectPath = "./tests/Cake.Common.Tests/";
106+
fixture.Command = "C:\\example\\path with\\spaces";
107+
fixture.Settings = new DotNetToolSettings();
108+
109+
// When
110+
var result = fixture.Run();
111+
112+
// Then
113+
Assert.Equal("\"C:\\example\\path with\\spaces\"", result.Args);
114+
}
99115
}
100116
}
101117
}

src/Cake.Common/Tools/DotNet/Tool/DotNetToolRunner.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ private ProcessArgumentBuilder GetArguments(string command, ProcessArgumentBuild
6060
{
6161
var builder = CreateArgumentBuilder(settings);
6262

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

6567
// Arguments
6668
if (!arguments.IsNullOrEmpty())

0 commit comments

Comments
 (0)