Post-build powershell script

安稳与你 提交于 2019-12-22 06:04:05

问题


I have the following post-build event:

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

and PS script beginning with:

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

when MSBuild trys to run it, my first parameter "$(SolutionDir)" is splitted in two parameters because the solution path contains a space character: D:\Projects\Dion2 Mercurial\repo\Dion2Web\. So my script receives D:\Projects\Dion2 as the first parameter and Mercurial\repo\Dion2Web\ as the second one.

What is the correct way to send those parameters to the script file?

Note: such post-build scripts works fine when script has only one parameter.


回答1:


Try adjusting your post build event to use the following:

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


来源:https://stackoverflow.com/questions/15929615/post-build-powershell-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!