Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,20 @@ private static ProcessResult RunProcess(string fileName, string arguments)
CreateNoWindow = true
};

// Reused MSBuild nodes outlive the build and inherit the redirected pipes, so reading
// stdout/stderr to the end would block until their idle timeout expires.
startInfo.Environment["MSBUILDDISABLENODEREUSE"] = "1";

using var process = new Process { StartInfo = startInfo };
process.Start();

// Drain both streams concurrently; reading them one after another can deadlock once the
// other pipe's buffer is full.
var error = process.StandardError.ReadToEndAsync();
var output = process.StandardOutput.ReadToEnd();
var error = process.StandardError.ReadToEnd();
process.WaitForExit();

return new ProcessResult(process.ExitCode, string.Concat(output, error));
return new ProcessResult(process.ExitCode, string.Concat(output, error.Result));
}

private sealed record ProcessResult(int ExitCode, string Output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ private static ProcessResult RunProcess(
CreateNoWindow = true
};

// Reused MSBuild nodes outlive the build and inherit the redirected pipes, so reading
// stdout/stderr to the end would block until their idle timeout expires.
process.StartInfo.Environment["MSBUILDDISABLENODEREUSE"] = "1";

process.Start();
var stdOut = process.StandardOutput.ReadToEndAsync();
var stdErr = process.StandardError.ReadToEndAsync();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<!-- Allow the tests to run where only a newer runtime is installed (e.g. the dotnet/sdk:10.0 CI image). -->
<RollForward>Major</RollForward>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Loading