Repository navigation
Fix DotNetTool path quoting for paths with spaces - #3737
Conversation
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/
There was a problem hiding this comment.
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.
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
Co-authored-by: Copilot <[email protected]>
ericstj
left a comment
There was a problem hiding this comment.
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.
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]>
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]>
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:
Total: 34 individual fixes across 14 files