Question

I'm trying to figure out how to call a PowerShell script with spaces in the filename as a Delphi build event.

From CMD I have to call powershell.exe -Command "& 'Filename With Spaces.ps1'" which works fine.

Delphi on the other hand doubles the ampersand sign and is trying to turn the command into two commands.

I have tried to set this as the build event:

powershell.exe -Command "& '$(PROJECTDIR)\Prebuild.ps1' $(PROJECTDIR)"

What gets executed by MSBuild is:

powershell.exe -Command "&& 'D:\SVN\AccuLib 3.0\VCLUI\Prebuild.ps1' D:\SVN\AccuLib 3.0\VCLUI"

So what does it take to call a ps1 file containing spaces from a Delphi build event?

Was it helpful?

Solution

Try the File parameter instead, it doesnt require an ampersand:

powershell.exe -File "Filename With Spaces.ps1"

OTHER TIPS

To use an ampersand sign you can create an intermediate cmd script.

Delphi build event:

Prebuild.cmd "$(PROJECTDIR)"

Prebuild.cmd file:

powershell.exe -Command "& 'Filename With Spaces.ps1'"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top