简体   繁体   中英

VSTS release, CMD webdeploy with variables inside Powershell quotation syntax

Apologies in advance if this is dumb and obvious. I have the following lines in a Powershell script executing as a release task in VSTS:

Write-Output "Stopping IIS..."  
CMD.exe /C "'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' -verb:sync -source:recycleApp -dest:recycleApp='MyApp/MyAppPool',recycleMode='StopAppPool',computername=$privateIp,userName=$serverLogin,password=$serverPassword"

It produces the following output:

2017-10-07T15:07:33.3282985Z Stopping IIS...
2017-10-07T15:07:34.5470804Z ##[error]The filename, directory name, or volume label syntax is incorrect

Per MS ( https://technet.microsoft.com/en-us/library/cc956689.aspx ) this means one of the following characters is wrong: \\ \\ / [ ] : | < > + ; = . ? "

I can only assume it's my quote syntax because that's the only character used on this line. I know it's not the contents of any of the variables, because they are used elsewhere in the script with no problem (and don't contain any of the characters in question).

Help?

After a lot of trial and error, I figured out the answer:

CMD.exe /C "`"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe`" -verb:sync -source:recycleApp -dest:recycleApp='MySite/MySiteAppPool',recycleMode='StopAppPool',computername=$privateIp,userName=$serverLogin,password=$serverPassword"   

Just a note for posterity, this is specifically a syntax that will work when you are attempting to stop/start/recycle an app pool on a server on the network, from a Powershell script, as a release task in VSTS, using msdeploy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM