msdeploy - What is up with this PowerShell command line quoting/escaping? -
i don't know i'm doing.
i have got powershell command work. can't figure out why works.
my concern final "" chars:
&"c:\program files\iis\microsoft web deploy\msdeploy.exe" ` -verb:sync ` -source:contentpath="$build_directory\deploy" ` -dest:contentpath="$server_temp_directory,computername=$server,username=$server_username,password=$server_password" ` -verbose ` -postsync=runcommand="powershell -nologo -noprofile -command $server_temp_directory\remotetasks.ps1 deploy""
why need double double-quotes?
my ide (powergui) says line not ended correctly, way can make command run wanted.
what it, - , ide - don't know qouting in powershell?
a little output echoargs:
if run:
echoargs -postsync=runcommand="powershell -nologo -noprofile -command $server_temp_directory\remotetasks.ps1 deploy""
i get:
arg 0 <-postsync=runcommand=powershell -nologo -noprofile -command \remotetasks.ps1 deploy>
if run without double double-quotes, get:
arg 0 <-postsync=runcommand=powershell> arg 1 <-nologo> arg 2 <-noprofile> arg 3 <-command> arg 4 <\remotetasks.ps1> arg 5 <deploy>
another thing notice is, above command work if uses = instead of : in last argument.
this won't work:
-postsync:runcommand="powershell -nologo -noprofile -command $server_temp_directory\remotetasks.ps1 deploy""
edit
now have tried array solution this:
$arguments = @("-verb:sync", "-source:contentpath=$build_directory\deploy", "-dest:contentpath=$server_temp_directory,computername=$server,username=$server_username,password=$server_password", "-verbose", "-postsynconsuccess:runcommand=powershell -command $server_temp_directory\remotetasks.ps1 deploy") &"c:\program files\iis\microsoft web deploy\msdeploy.exe" $arguments
i still same error:
error: unrecognized argument '"-postsynconsuccess:runcommand=powershell -command c:\temp\kslog\remotetasks.ps1 deploy"'. arguments must begin "-".
am doing new thing wrong here?
this notorious issue. ticket “executing commands require quotes , variables practically impossible” voted bug: https://connect.microsoft.com/powershell/feedback
you can find there few workarounds well. recommend compose parameters array , use &
operator invoke native command array. see answers , examples: running exe file using powershell directory spaces in it , executing command stored in variable powershell
i did not work msdeploy.exe
, cannot provide demo code case. applied approach many other tricky native commands enough. please, try , let know results.
p.s. technically not answer questions assume still looking practical way of doing this, still might helpful.
Comments
Post a Comment