From 59b39d5f4aebb8e2c035567fb1a26fa539636777 Mon Sep 17 00:00:00 2001 From: CrispyDrone <37639058+CrispyDrone@users.noreply.github.com> Date: Sat, 21 Nov 2020 15:00:01 +0100 Subject: [PATCH] fix: Fix NuGet from hanging (#1044) It is important to read both stdout and stderr lest their buffers fill up, and the process sits there waiting for eternity. I don't know if this is specific to how a process interacts with its console handles, or whether this is determined by the OS. --- NuKeeper.Update/ProcessRunner/ExternalProcess.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/NuKeeper.Update/ProcessRunner/ExternalProcess.cs b/NuKeeper.Update/ProcessRunner/ExternalProcess.cs index cf7098a89..8a9bc17f5 100644 --- a/NuKeeper.Update/ProcessRunner/ExternalProcess.cs +++ b/NuKeeper.Update/ProcessRunner/ExternalProcess.cs @@ -1,8 +1,8 @@ +using NuKeeper.Abstractions; +using NuKeeper.Abstractions.Logging; using System; using System.Diagnostics; using System.Threading.Tasks; -using NuKeeper.Abstractions; -using NuKeeper.Abstractions.Logging; namespace NuKeeper.Update.ProcessRunner { @@ -44,8 +44,13 @@ public async Task Run(string workingDirectory, string command, st throw new NuKeeperException($"Could not start external process for {command}"); } - var textOut = await process.StandardOutput.ReadToEndAsync(); - var errorOut = await process.StandardError.ReadToEndAsync(); + var outputs = await Task.WhenAll( + process.StandardOutput.ReadToEndAsync(), + process.StandardError.ReadToEndAsync() + ); + + var textOut = outputs[0]; + var errorOut = outputs[1]; process.WaitForExit();