wait for log drain

This commit is contained in:
Matt Parker
2025-08-08 02:20:43 +10:00
parent ea5bb6ac53
commit c08fad9e01
2 changed files with 6 additions and 2 deletions

View File

@@ -33,13 +33,14 @@ public class RunService
RedirectStandardError = true
};
await using var process = new AsyncReadProcess.Process2()
var process = new AsyncReadProcess.Process2
{
StartInfo = processStartInfo
};
process.Start();
var logsDrained = new TaskCompletionSource();
_ = Task.Run(async () =>
{
await foreach(var log in process.CombinedOutputChannel.Reader.ReadAllAsync())
@@ -47,6 +48,7 @@ public class RunService
var logString = System.Text.Encoding.UTF8.GetString(log, 0, log.Length);
Console.Write(logString);
}
logsDrained.TrySetResult();
});
project.Running = true;
@@ -57,6 +59,8 @@ public class RunService
process.End();
await process.WaitForExitAsync();
}
await logsDrained.Task;
project.Running = false;
GlobalEvents.InvokeProjectsRunningChanged();

View File

@@ -9,7 +9,7 @@
<ItemGroup>
<!-- If any Microsoft.Build.dll ends up in the output, it will be prioritised for loading by MSBuild Nodes -->
<PackageReference Include="Ardalis.GuardClauses" Version="5.0.0" />
<PackageReference Include="AsyncReadProcess" Version="1.0.0-preview6" />
<PackageReference Include="AsyncReadProcess" Version="1.0.0-preview7" />
<PackageReference Include="Microsoft.Build" Version="17.14.8" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Framework" Version="17.14.8" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.9.1" />