From 29ac66f7d2647b820dfc36bbbc30b6951220c39e Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Sat, 24 Mar 2018 11:59:36 -0500 Subject: [PATCH] Keep stdout for test execution Work around https://github.com/Microsoft/vstest/issues/1503 by using the MSBuild escape hatch variable MSBUILDENSURESTDOUTFORTASKPROCESSES and ensuring that tests don't run in a disconnected MSBuild process by passing /nr:false. --- src/dotnet/commands/dotnet-test/Program.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/dotnet/commands/dotnet-test/Program.cs b/src/dotnet/commands/dotnet-test/Program.cs index d714d2f9e9..8e837ae4c5 100644 --- a/src/dotnet/commands/dotnet-test/Program.cs +++ b/src/dotnet/commands/dotnet-test/Program.cs @@ -32,6 +32,7 @@ public static TestCommand FromArgs(string[] args, string msbuildPath = null) { "/t:VSTest", "/v:quiet", + "/nodereuse:false", // workaround for https://github.com/Microsoft/vstest/issues/1503 "/nologo" }; @@ -95,7 +96,23 @@ public static int Run(string[] args) return e.ExitCode; } - return cmd.Execute(); + // Workaround for https://github.com/Microsoft/vstest/issues/1503 + const string NodeWindowEnvironmentName = "MSBUILDENSURESTDOUTFORTASKPROCESSES"; + string previousNodeWindowSetting = Environment.GetEnvironmentVariable(NodeWindowEnvironmentName); + + int result = -1; + + try + { + Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, "1"); + result = cmd.Execute(); + } + finally + { + Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, previousNodeWindowSetting); + } + + return result; } private static string GetSemiColonEscapedString(string arg)