Running PowerShell from MSdeploy runcommand does not exit Running PowerShell from MSdeploy runcommand does not exit powershell powershell

Running PowerShell from MSdeploy runcommand does not exit


Your scenario and problem look similar to this reported issue:PowerShell.exe can hang if STDIN is redirected

If this is the case then try this workaround: use -inputformat none:

powershell.exe -inputformat none C:\temp\WebDeploy\Package\HelloWorld.ps1

I have tried this with "a fake msdeploy" program that calls the .bat file like this:

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();    }}

This demo does have the same problem that you describe and the workaround helps. If msdeploy calls the .bat file in the same or similar way then hopefully this is a solution.


powershell.exe -file ScriptFile.ps < CON

This solve the problem without resorting to undocumented features.