我试图在 MSDeploy 命令的 preSync 调用期间调用 powershell,但 powershell 在调用后不会退出该进程。命令(来自命令行):“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
我在这里使用了一个hack(http://therightstuff.de/2010/02/06/How-We-Practice-Continuous-Integration-And-Deployment-With-MSDeploy.aspx),它获取了powershell进程并杀死了它,但是没用。我还尝试了 taskkill 和 sysinternals 等效项,但没有任何东西会终止该进程,以便 MSDeploy 出错。该命令已执行,但随后就坐在那里。任何想法可能导致powershell像这样挂起?我在网上发现了一些其他类似的问题,但没有答案。
环境是Win 2K3,使用Powershell 2.0。
更新:这是我现在用来调用我的 powershell 命令的 .vbs 脚本。使用 '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 = oShell.Exec(appCmd)
oShellExec.StdIn.Close()