Skip to content

Conversation

@antonysmith-mandogroup
Copy link
Contributor

As per discussion in #4286, this PR resolves an issue where the command passed to DotNetToolRunner is the path of an application to run and it contains whitespace.

Sample verbose output before this change:

begin /k:"test-project" /n:"Test Project" /d:sonar.login="[REDACTED]"
We're launching for CoreCLR with executable C:/tmp/Cake Test/tools/dotnet-sonarscanner.10.3.0/tools/netcoreapp3.1/any/SonarScanner.MSBuild.dll
Resolved tool to path C:/Program Files/dotnet/dotnet.exe
Executing: "C:/Program Files/dotnet/dotnet.exe" C:/tmp/Cake Test/tools/dotnet-sonarscanner.10.3.0/tools/netcoreapp3.1/any/SonarScanner.MSBuild.dll begin /k:"test-project" /n:"Test Project" /d:sonar.login="[REDACTED]"
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-C:/tmp/Cake does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
An error occurred when executing task 'Sonar-Qube-Start-Analysis'.

Output following the change - note the surrounding quotes around the application being run:

begin /k:"test-project" /n:"Test Project" /d:sonar.login="[REDACTED]"
We're launching for CoreCLR with executable C:/tmp/Cake Test/tools/dotnet-sonarscanner.10.3.0/tools/netcoreapp3.1/any/SonarScanner.MSBuild.dll
Resolved tool to path C:/Program Files/dotnet/dotnet.exe
Executing: "C:/Program Files/dotnet/dotnet.exe" "C:/tmp/Cake Test/tools/dotnet-sonarscanner.10.3.0/tools/netcoreapp3.1/any/SonarScanner.MSBuild.dll" begin /k:"test-project" /n:"Test Project" /d:sonar.login="[REDACTED]"
SonarScanner for MSBuild 10.3
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.

All unit tests (that I can run on my Windows machine) pass:

image

This includes a new test I have added to verify that the command is now quoted.

@antonysmith-mandogroup
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Mando Group"

@devlead devlead changed the title (GH-4286) Update DotNetToolRunner to append command using quotes GH4286: Update DotNetToolRunner to append command using quotes Aug 6, 2025
@devlead devlead enabled auto-merge August 6, 2025 08:09
@devlead devlead linked an issue Aug 6, 2025 that may be closed by this pull request
2 tasks
Copy link
Member

@devlead devlead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@devlead devlead merged commit 7f89aaf into cake-build:develop Aug 6, 2025
16 checks passed
@devlead
Copy link
Member

devlead commented Aug 6, 2025

@antonysmith-mandogroup your changes have been merged, thanks for your contribution 👍

This was referenced Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DotNetToolRunner doesn't support empty space at tool path

2 participants