Fix escaping for dotnet paths with spaces when spawning out-of-proc nodes#12644
Merged
rainersigwald merged 2 commits intovs18.0from Oct 20, 2025
Merged
Fix escaping for dotnet paths with spaces when spawning out-of-proc nodes#12644rainersigwald merged 2 commits intovs18.0from
rainersigwald merged 2 commits intovs18.0from
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes escaping for paths containing spaces when launching dotnet/MSBuild processes. The primary issue was that paths with spaces were not properly quoted, causing process launch failures where the path would be truncated at the first space character.
- Adds proper quoting for MSBuild.dll path in command line arguments
- Updates test infrastructure to support validation of path escaping
- Adds comprehensive test to verify correct path handling with spaces
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs | Added quotes around MSBuild.dll path in command line template |
| src/UnitTests.Shared/TestEnvironment.cs | Refactored test environment setup and added method to retrieve environment variables |
| src/Build.UnitTests/NetTaskHost_E2E_Tests.cs | Updated tests to use new test environment setup and added comprehensive path escaping validation |
| src/Build.UnitTests/TestAssets/ExampleNetTask/ExampleTask/ExampleTask.cs | Added command line argument logging for test validation |
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs
Show resolved
Hide resolved
baronfel
approved these changes
Oct 15, 2025
rainersigwald
approved these changes
Oct 20, 2025
This was referenced Oct 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
When a path to dotnet.exe or MSBuild.dll contains spaces, it's incorrectly escaped and causes errors like this:
Could not execute because the specified command or file was not found.
The path gets truncated at the space character, causing the process launch to fail.
The important notice – it’s a critical scenario for the feature dogfooding , since dotnet.exe usually is placed in “Program Files” (path with spaces).
It wasn’t caught during the development because msbuild has a bootstrapped copy of the sdk and this path was ok ☹
Changes Made
Added proper escaping for the msbuild.dll path to ensure it works correctly even when the path contains spaces.
Regression
No, it’s a bug in the new feature
Risks
No risks, minimal well-boxed change
Testing
UT + manual
Notes
This logic is taken from #12630