Skip to content

Quote paths with spaces in MSBuild bootstrap InstallDotNetCoreTask - #7075

Merged
lewing merged 1 commit into
mainfrom
fix/msbuild-bootstrap-path-quoting
Jun 5, 2026
Merged

lewing merged 1 commit into
mainfrom
fix/msbuild-bootstrap-path-quoting

Conversation

@lewing

@lewing lewing commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

Fixes MSBuild bootstrap Install-scripts was not executed successfully failure on Windows when DotNetRoot resolves to a path with spaces (e.g., C:\Program Files\dotnet\).

Root Cause

When 1ES build agents have SDK 10.0.300 installed system-wide at C:\Program Files\dotnet\, arcade's provisioning skips .dotnet setup since the version is already present. This causes $(DotNetRoot) to resolve to C:\Program Files\dotnet\ instead of the repo-local .dotnet\ directory.

InstallDotNetCoreTask passes the script path unquoted to PowerShell's -File parameter:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\Program Files\dotnet\dotnet-install.ps1 ...

PowerShell splits on the space and tries to interpret C:\Program as the script file:

Processing -File 'C:\Program' failed because the file does not have a '.ps1' extension.

This was confirmed by downloading the binlog from a failing PR build (build 1450966) and finding:

  • DotNetInstallScriptRootPath = C:\Program Files\dotnet\
  • Processing -File 'C:\Program' failed because the file does not have a '.ps1' extension.

Fix

Quote scriptPath and InstallDir in the command argument strings for both Windows and Unix, and also quote the chmod argument.

Same class of fix as #3737.

Impact

  • Currently broken: All Windows legs on release/10.0.4xx official and PR builds (builds 2992647, 1450748, 1450966, 1451266)
  • Will break: main and other branches when their agents get updated with system-wide SDK 10.0.300

This PR targets main so the fix backflows to all branches. Cherry-pick to release/10.0.4xx recommended for immediate unblock.

Copilot AI review requested due to automatic review settings June 5, 2026 12:58
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team June 5, 2026 12:59
@lewing
lewing requested review from ViktorHofer and akoeplinger June 5, 2026 13:00
@dotnet dotnet deleted a comment from github-actions Bot Jun 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes MSBuild bootstrap failures caused by invoking the dotnet-install script with unquoted paths when $(DotNetRoot) (and related paths) contain spaces, particularly on Windows agents with system-wide SDK installs under C:\Program Files\dotnet\.

Changes:

  • Quote the dotnet-install script path when passed to PowerShell (-File) and to /bin/bash.
  • Quote InstallDir when passed to the install scripts on both Windows and Unix.
  • Quote the chmod target path when making the script executable on non-Windows platforms.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

When DotNetRoot resolves to a path with spaces (e.g. C:\Program Files\dotnet\),
the dotnet-install script path and install directory are split on the space
character, causing powershell.exe -File to fail with:

  Processing -File C:\Program failed because the file does not have
  a .ps1 extension.

This quotes scriptPath and InstallDir in the PowerShell and bash argument
strings, and also quotes the chmod argument on Unix.

Same class of fix as #3737.

Co-authored-by: Copilot <[email protected]>
@lewing
lewing force-pushed the fix/msbuild-bootstrap-path-quoting branch from f69c910 to eefaa43 Compare June 5, 2026 13:09
@lewing
lewing enabled auto-merge (squash) June 5, 2026 14:29
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team June 5, 2026 14:29
@lewing
lewing merged commit d233c67 into main Jun 5, 2026
11 checks passed
@lewing
lewing deleted the fix/msbuild-bootstrap-path-quoting branch June 5, 2026 15:26
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.

3 participants