post-build powershell脚本

我有以下post-build事件:

powershell Set-ExecutionPolicy Unrestricted powershell -file "$(SolutionDir)Obfuscation\_obfuscate.ps1" "$(SolutionDir)" "$(ProjectDir)" powershell Set-ExecutionPolicy Restricted 

和PS脚本开头:

 param ( [string]$slnDir, [string]$projectDir ) 

当MSBuild尝试运行它时,我的第一个参数"$(SolutionDir)"被分成两个参数,因为解决方案路径包含一个空格字符: D:\Projects\Dion2 Mercurial\repo\Dion2Web\ 。 所以我的脚本接收D:\Projects\Dion2作为第一个参数, Mercurial\repo\Dion2Web\作为第二个参数。

将这些参数发送到脚本文件的正确方法是什么?

注意:当脚本只有一个参数时,这样的构建后脚本可以正常工作。

尝试调整post build事件以使用以下内容:

 powershell -file "$(SolutionDir)Obfuscation\_obfuscate.ps1" -slnDir '$(SolutionDir)' -projectDir '$(ProjectDir)' 
Interesting Posts