Skip to content
Closed
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
14 changes: 11 additions & 3 deletions src/MSBuild.UnitTests/MSBuildServer_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,24 @@ public void CanShutdownServerProcess(bool byBuildManager)

if (byBuildManager)
{
BuildManager.DefaultBuildManager.ShutdownAllNodes();
// ShutdownAllNodes does not expose whether the MSBuildServer was successfully
// contacted. The server may be recycling its pipe right after the build completes
// (busy mutex released before new pipe is ready), causing the first attempt to
// silently fail. Retry until the process exits or a reasonable timeout elapses.
Stopwatch sw = Stopwatch.StartNew();
while (!serverProcess.HasExited && sw.ElapsedMilliseconds < 10_000)
{
BuildManager.DefaultBuildManager.ShutdownAllNodes();
serverProcess.WaitForExit(500);
}
}
else
{
bool serverIsDown = MSBuildClient.ShutdownServer(CancellationToken.None);
serverIsDown.ShouldBeTrue();
serverProcess.WaitForExit(10_000);
}

serverProcess.WaitForExit(10_000);

serverProcess.HasExited.ShouldBeTrue();
}

Expand Down
Loading