diff --git a/dotnet/tests/Microsoft.Agents.AI.DurableTask.IntegrationTests/ConsoleAppSamplesValidation.cs b/dotnet/tests/Microsoft.Agents.AI.DurableTask.IntegrationTests/ConsoleAppSamplesValidation.cs index 2f509962eb..44c0fb116d 100644 --- a/dotnet/tests/Microsoft.Agents.AI.DurableTask.IntegrationTests/ConsoleAppSamplesValidation.cs +++ b/dotnet/tests/Microsoft.Agents.AI.DurableTask.IntegrationTests/ConsoleAppSamplesValidation.cs @@ -832,12 +832,17 @@ private async Task BuildSampleAsync(string samplePath) using Process buildProcess = new() { StartInfo = buildInfo }; buildProcess.Start(); + + // Read both streams asynchronously to avoid deadlocks from filled pipe buffers + Task stdoutTask = buildProcess.StandardOutput.ReadToEndAsync(); + Task stderrTask = buildProcess.StandardError.ReadToEndAsync(); await buildProcess.WaitForExitAsync(); + string stderr = await stderrTask; if (buildProcess.ExitCode != 0) { - string stderr = await buildProcess.StandardError.ReadToEndAsync(); - throw new InvalidOperationException($"Failed to build sample at {samplePath}: {stderr}"); + string stdout = await stdoutTask; + throw new InvalidOperationException($"Failed to build sample at {samplePath}:\n{stdout}\n{stderr}"); } this._outputHelper.WriteLine($"Build completed for {samplePath}."); diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests/SamplesValidation.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests/SamplesValidation.cs index 5b1e46ebf0..919f66f30b 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests/SamplesValidation.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests/SamplesValidation.cs @@ -830,12 +830,17 @@ private async Task BuildSampleAsync(string samplePath) using Process buildProcess = new() { StartInfo = buildInfo }; buildProcess.Start(); + + // Read both streams asynchronously to avoid deadlocks from filled pipe buffers + Task stdoutTask = buildProcess.StandardOutput.ReadToEndAsync(); + Task stderrTask = buildProcess.StandardError.ReadToEndAsync(); await buildProcess.WaitForExitAsync(); + string stderr = await stderrTask; if (buildProcess.ExitCode != 0) { - string stderr = await buildProcess.StandardError.ReadToEndAsync(); - throw new InvalidOperationException($"Failed to build sample at {samplePath}: {stderr}"); + string stdout = await stdoutTask; + throw new InvalidOperationException($"Failed to build sample at {samplePath}:\n{stdout}\n{stderr}"); } this._outputHelper.WriteLine($"Build completed for {samplePath}.");