如何在构建事件中使用&符号?

Jen*_*off 3 delphi powershell build-events delphi-xe2

我试图弄清楚如何调用PowerShell脚本,在文件名中使用空格作为Delphi构建事件.

从CMD我必须打电话powershell.exe -Command "& 'Filename With Spaces.ps1'"哪个工作正常.

另一方面,Delphi将&符号加倍,并试图将命令转换为两个命令.

我试图将其设置为构建事件:

powershell.exe -Command "& '$(PROJECTDIR)\Prebuild.ps1' $(PROJECTDIR)"
Run Code Online (Sandbox Code Playgroud)

MSBuild执行的是:

powershell.exe -Command "&& 'D:\SVN\AccuLib 3.0\VCLUI\Prebuild.ps1' D:\SVN\AccuLib 3.0\VCLUI"
Run Code Online (Sandbox Code Playgroud)

那么ps1从Delphi构建事件中调用包含空格的文件需要什么呢?

Sha*_*evy 5

请尝试使用File参数,它不需要&符号:

powershell.exe -File "Filename With Spaces.ps1"
Run Code Online (Sandbox Code Playgroud)