【问题标题】:Powershell 2.0 Hang When Run From MsDeploy pre- post- ops using c/Powershell 2.0 在使用 c/ 从 MsDeploy pre-post-ops 运行时挂起
【发布时间】:2011-02-17 07:02:45
【问题描述】:

我试图在 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()

【问题讨论】:

  • 任何带有完整源代码的最终解决方案?

标签: powershell msdeploy


【解决方案1】:

以防万一有人正在为批处理文件寻找类似的解决方案: 看看这里 http://epeleg.blogspot.com/2010/06/solution-to-powershell-never-exists.html

小故事:使用

【讨论】:

  • 做 msdeploy.exe -verb:sync -source:runco​​mmand="powershell -NoProfile c:\deploy\deploy.ps1
【解决方案2】:

查看proposed solution on this site。 PowerShell.exe 似乎不想在像这样执行时退出,直到它的标准输入被调用进程关闭。

【讨论】:

  • Keith,这确实解决了问题。我还在 ps1 中尝试了 [Console]::In.Close() ,但它不起作用,所以我想我必须在 wscript 中托管。非常感谢!
【解决方案3】:

您是否尝试过使用此命令?停止进程 $pid 。 $pid 是当前 pid 的内置 powershell 变量。我有这个在服务器 2008 R2 服务器上工作,用于 codecampserver 项目。您可以在此处查看运行它的构建:http://build-oss.headspringlabs.com。我注意到从预同步中尝试过这个,但我认为这不会影响远程会话。

【讨论】:

  • Eric 我认为这实际上是我开始使用的代码! :) 我在 Win 2K3 上运行,但它仍然不适用于任何 Stop-Process 调用。我不得不在 wscript 中托管 PS 以杀死 StdIn。
  • 哇,很高兴知道.. 这听起来确实像一个错误。 stop-process 应该在不同的服务器操作系统中执行相同的操作。
猜你喜欢
  • 1970-01-01
  • 2011-05-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-21
  • 2019-01-08
  • 2021-12-29
  • 2020-11-09
相关资源
最近更新 更多