Skip to content

Fix DotNetTool path quoting for paths with spaces - #3737

Merged
lewing merged 4 commits into
mainfrom
fix-dotnettool-path-quoting
Dec 9, 2025
Merged

lewing merged 4 commits into
mainfrom
fix-dotnettool-path-quoting

Conversation

@lewing

@lewing lewing commented Dec 8, 2025 •

Copy link
Copy Markdown
Member

Fixes an issue where Exec commands were not quoting the $(DotNetTool) variable, causing build failures when dotnet.exe is installed in a path with spaces (e.g., C:\Program Files\dotnet\dotnet.exe).

This applies the same fix from dotnet/arcade#16381 to all occurrences in the dotnet/dotnet repository.

Changes

Changed Command="$(DotNetTool) ..." to Command=""$(DotNetTool)" ..." in:

  • src/diagnostics/src/SOS/SOS.Package/SOS.Package.csproj
  • src/runtime/src/mono/sample/Android/AndroidSampleApp.csproj
  • src/sdk/src/Layout/redist/targets/OverlaySdkOnLKG.targets
  • src/arcade/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/wix.targets
  • src/arcade/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix5/wix.targets
  • repo-projects/Directory.Build.targets
  • src/source-build-reference-packages/src/externalPackages/projects/application-insights.proj (3 fixes)
  • src/source-build-reference-packages/src/externalPackages/projects/azure-activedirectory-identitymodel-extensions-for-dotnet.proj (6 fixes)
  • src/source-build-reference-packages/src/externalPackages/projects/cssparser.proj (3 fixes)
  • src/source-build-reference-packages/src/externalPackages/projects/docker-creds-provider.proj (3 fixes)
  • src/source-build-reference-packages/src/externalPackages/projects/MSBuildLocator.proj (3 fixes)
  • src/source-build-reference-packages/src/externalPackages/projects/newtonsoft-json.proj
  • src/source-build-reference-packages/src/externalPackages/projects/spectre-console.proj (3 fixes)
  • src/source-build-reference-packages/src/externalPackages/projects/humanizer.proj (3 fixes)

Total: 34 individual fixes across 14 files

Fixes an issue where Exec commands were not quoting the DotNetTool variable, causing build failures when dotnet.exe is installed in a path with spaces (e.g., 'C:\Program Files\dotnet\dotnet.exe').

This applies the same fix from dotnet/arcade#16381 to all occurrences in the dotnet/dotnet repository.

Changed Command="$(DotNetTool) ..." to Command=""$(DotNetTool)" ..." in:

- src/diagnostics/src/SOS/SOS.Package/SOS.Package.csproj

- src/runtime/src/mono/sample/Android/AndroidSampleApp.csproj

- src/sdk/src/Layout/redist/targets/OverlaySdkOnLKG.targets

- src/arcade wix/wix.targets and wix5/wix.targets

- repo-projects/Directory.Build.targets

- 8 files in src/source-build-reference-packages/src/externalPackages/projects/
Copilot AI review requested due to automatic review settings December 8, 2025 19:18
@lewing
lewing requested review from a team as code owners December 8, 2025 19:18
@dotnet-policy-service
dotnet-policy-service Bot requested review from a team December 8, 2025 19:18
@lewing
lewing requested a review from ericstj December 8, 2025 19:18

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

This PR fixes build failures that occur when the .NET SDK is installed in a path containing spaces (e.g., "C:\Program Files\dotnet\dotnet.exe") by adding proper quoting around the $(DotNetTool) MSBuild property in Exec commands. The fix applies the same solution from a previous Arcade SDK change (PR #16381) to 34 occurrences across 14 files in the dotnet/dotnet repository.

  • Adds XML entity-encoded quotes (") around $(DotNetTool) references in MSBuild Exec commands
  • Ensures build commands (restore, build, pack) work correctly with space-containing paths
  • Maintains consistency with existing quoting patterns in the codebase

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/source-build-reference-packages/src/externalPackages/projects/spectre-console.proj Quotes DotNetTool in restore, build, and pack commands
src/source-build-reference-packages/src/externalPackages/projects/newtonsoft-json.proj Quotes DotNetTool in restore command
src/source-build-reference-packages/src/externalPackages/projects/humanizer.proj Quotes DotNetTool in restore, build, and pack commands
src/source-build-reference-packages/src/externalPackages/projects/docker-creds-provider.proj Quotes DotNetTool in restore, build, and pack commands
src/source-build-reference-packages/src/externalPackages/projects/cssparser.proj Quotes DotNetTool in restore, build, and pack commands
src/source-build-reference-packages/src/externalPackages/projects/azure-activedirectory-identitymodel-extensions-for-dotnet.proj Quotes DotNetTool in restore, build, and multiple pack commands
src/source-build-reference-packages/src/externalPackages/projects/application-insights.proj Quotes DotNetTool in restore, build, and pack commands
src/source-build-reference-packages/src/externalPackages/projects/MSBuildLocator.proj Quotes DotNetTool in restore, build, and pack commands
src/sdk/src/Layout/redist/targets/OverlaySdkOnLKG.targets Quotes DotNetTool in version check command (note: uses incorrect casing)
src/runtime/src/mono/sample/Android/AndroidSampleApp.csproj Quotes DotNetTool in xharness android test command
src/diagnostics/src/SOS/SOS.Package/SOS.Package.csproj Quotes DotNetTool in manifest generation command
src/arcade/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix5/wix.targets Quotes DotNetTool in pack command for VS insertion packages
src/arcade/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/wix.targets Quotes DotNetTool in pack command for VS insertion packages
repo-projects/Directory.Build.targets Quotes DotNetTool in build-server shutdown command

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

lewing and others added 2 commits December 8, 2025 13:25
This adds quotes around , , and  variables to handle paths with spaces.

Files modified:

- src/diagnostics/src/SOS/SOS.Package/SOS.Package.csproj

- src/runtime/src/mono/sample/Android/AndroidSampleApp.csproj

- src/runtime/src/mono/sample/iOS/Program.csproj

- src/runtime/src/mono/sample/iOS-NativeAOT/Program.csproj

- src/runtime/src/mono/sample/mbr/apple/AppleDelta.csproj
@lewing
lewing marked this pull request as draft December 8, 2025 19:28

@ericstj ericstj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks reasonable to me. The only risk here would be double quoting - I looked for evidence of this for each property but couldn't find any conern around the source property being quoted.

@steveisok
steveisok self-requested a review December 8, 2025 20:05
@lewing
lewing marked this pull request as ready for review December 8, 2025 20:21
@lewing
lewing enabled auto-merge December 8, 2025 20:27
@lewing
lewing merged commit 317eb53 into main Dec 9, 2025
@lewing
lewing deleted the fix-dotnettool-path-quoting branch December 9, 2025 02:06
lewing added a commit that referenced this pull request Jun 5, 2026
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 added a commit that referenced this pull request Jun 5, 2026
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]>
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.

4 participants