开发者

Powershell 2.0 Hang When Run From MsDeploy pre- post- ops using c/

开发者 https://www.devze.com 2022-12-29 10:47 出处:网络
I am trying to invoke powershell during the preSync call in a MSDeploy command, but powershell does not exit the process after it has been called.

I am trying to invoke powershell during the preSync call in a MSDeploy command, but powershell does not exit the process after it has been called. The command (from command line): "tools/MSDeploy/msdeploy.exe" -verb:sync -preSync:runCommand="powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command C:/MyInstallPath/deploy.ps1 Set-WebAppOffline Uninstall-Service ",waitInterval=60000 -usechecksum -source:dirPath="build/for-deployment" -dest:wmsvc=BLUEPRINT-X86,username=deployer,password=deployer,dirPath=C:/MyInstallPath

I used a hack here (http://therightstuff.de/2010/02/06/How-We-Practice-Continuous-Integration-And-Deployment-With-MSDeploy.aspx) that gets the powershell process and kills it but that didn't work. I also tried taskkill and the sysinternals equivalent, but nothing will kill the process so that MSDeploy errors out. The command is executed, but then just sits there. Any ideas what might be causing powershell to hang like this? I have found a few other similar issues around the web but no answers.

Environment is Win 2K3, using Powershell 2.0.

UPDATE: Here is a .vbs script I use to invoke my powershell command now. Invoke using 'cscript.exe path/to/script.vbs':

Option Explicit
Dim oShell, appCmd,oShellExec
Set oShell = CreateObject("WScript.Shell")
appCmd = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ""&{ . c:/development/materialstesting/deploy/web/deploy.ps1; Set-WebAppOffline }"" "
Set oShellExec = oShe开发者_如何学运维ll.Exec(appCmd)
oShellExec.StdIn.Close()


Just in case someone is looking for a similar solution for a batch file: Have a look here http://epeleg.blogspot.com/2010/06/solution-to-powershell-never-exists.html

The short story: use <NUL


Look at the proposed solution on this site. It appears that PowerShell.exe doesn't want to exit when executed like this until its stdin has been closed by the invoking process.


Have you tried using this command? stop-process $pid . $pid is a built in powershell variable for the current pid. I have this working on a server 2008 R2 server, for the codecampserver project. You can view the build that runs this here: http://build-oss.headspringlabs.com. I have note tried this from a pre-sync but I do not think that should effect the remote session.

0

精彩评论

暂无评论...
验证码 换一张
取 消