Skip to content

Fix PowerShell PostBuild failing when solution path contains spaces#3669

Merged
christophwille merged 1 commit intoicsharpcode:masterfrom
Myself-Bloons:fix/powershell-postbuild-paths-with-spaces
Mar 24, 2026
Merged

Fix PowerShell PostBuild failing when solution path contains spaces#3669
christophwille merged 1 commit intoicsharpcode:masterfrom
Myself-Bloons:fix/powershell-postbuild-paths-with-spaces

Conversation

@Myself-Bloons
Copy link
Copy Markdown
Contributor

Summary

  • Quote $(ProjectDir) and $(TargetDir) MSBuild properties in the PowerShell Copy-Item commands in ICSharpCode.Decompiler.PowerShell.csproj
  • Without quotes, the PostBuild target fails with MSB3073 when the solution is cloned into a directory whose path contains spaces

Reproduction

  1. Clone the repo into a folder with a space in its name (e.g. C:\Dev\ILSpy 10.0)
  2. Run dotnet build ILSpy.sln --configuration Release
  3. Build fails with: error MSB3073: The command "powershell -Command "Copy-Item ..." exited with code 1

Fix

Wrap the path arguments in single quotes so PowerShell treats them as literal string paths:

<Exec Command="powershell -Command &quot;Copy-Item '$(ProjectDir)manifest.psd1' '$(TargetDir)$(TargetName).psd1'&quot;" />

Test plan

  • Verified build succeeds in a path with spaces (C:\Dev\IlySpy 10.0)
  • 0 warnings, 0 errors on full solution build

Quote the $(ProjectDir) and $(TargetDir) MSBuild properties in the
Copy-Item commands so that paths with spaces are handled correctly.
@christophwille christophwille merged commit a2c4dc8 into icsharpcode:master Mar 24, 2026
5 checks passed
@christophwille
Copy link
Copy Markdown
Member

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants