Pet*_*erg 17 powershell msdeploy webdeploy
我正在尝试让MSDeploy在远程服务器上执行PowerShell脚本.这是我执行MSDeploy的方式:
msdeploy \
-verb:sync \
-source:runCommand='C:\temp\HelloWorld.bat', \
waitInterval=15000,waitAttempts=1 \
-dest:auto,computername=$WebDeployService$Credentials -verbose
Run Code Online (Sandbox Code Playgroud)
HelloWorld.bat包含:
echo "Hello world!"
powershell.exe C:\temp\WebDeploy\Package\HelloWorld.ps1
echo "Done"
Run Code Online (Sandbox Code Playgroud)
HelloWorld.ps1仅包含:
Write-Host "Hello world from PowerShell!"
Run Code Online (Sandbox Code Playgroud)
但是,似乎PowerShell永远不会终止.这是运行msdeploy的输出:
Verbose: Performing synchronization pass #1.
Verbose: Source runCommand (C:\temp\HelloWorld.bat) does not match destination (C:\temp\HelloWorld.bat) differing in attributes (isSource['True','False']). Update pending.
Info: Updating runCommand (C:\temp\HelloWorld.bat).
Info:
Info: C:\temp>echo "Hello world!"
"Hello world!"
C:\temp\WebDeploy>powershell.exe C:\temp\HelloWorld.ps1
Info: Hello world from Powershell!
Info:
Warning: The process 'C:\Windows\system32\cmd.exe' (command line '/c "C:\Users\peter\AppData\Local\Temp\gaskgh55.b2q.bat
"') is still running. Waiting for 15000 ms (attempt 1 of 1).
Error: The process 'C:\Windows\system32\cmd.exe' (command line '/c "C:\Users\peter\AppData\Local\Temp\gaskgh55.b2q.bat"'
) was terminated because it exceeded the wait time.
Error count: 1.
Run Code Online (Sandbox Code Playgroud)
谁知道解决方案?
Rom*_*min 21
您的方案和问题看起来类似于此报告的问题: 如果重定向STDIN,PowerShell.exe可能会挂起
如果是这种情况,请尝试此解决方法:使用-inputformat none:
powershell.exe -inputformat none C:\temp\WebDeploy\Package\HelloWorld.ps1
Run Code Online (Sandbox Code Playgroud)
我试过这个"假的msdeploy"程序,它调用.bat文件,如下所示:
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
ProcessStartInfo si = new ProcessStartInfo();
si.FileName = "cmd.exe";
si.Arguments = "/c " + args[0];
si.RedirectStandardInput = true;
si.UseShellExecute = false;
var process = Process.Start(si);
process.WaitForExit();
}
}
Run Code Online (Sandbox Code Playgroud)
此演示确实具有您描述的相同问题,并且解决方法有所帮助.如果msdeploy以相同或类似的方式调用.bat文件,那么希望这是一个解决方案.
| 归档时间: |
|
| 查看次数: |
6499 次 |
| 最近记录: |