Post-build powershell script

I have the following event after the build:

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

and PS script, starting with:

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

when MSBuild tries to start it, my first parameter "$(SolutionDir)" is separated by two parameters, because the solution path contains a space character: D:\Projects\Dion2 Mercurial\repo\Dion2Web\ . Therefore, my script receives D:\Projects\Dion2 as the first parameter and Mercurial\repo\Dion2Web\ as the second.

What is the correct way to send these parameters to a script file?

Note: such post build scripts work great when the script has only one parameter.

+4
source share
1 answer

Try setting up the post build event to use the following:

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

All Articles