Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit d98928e

Browse files
committed
Keep stdout for test execution
Work around microsoft/vstest#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.
1 parent cd646d2 commit d98928e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/dotnet/commands/dotnet-test/Program.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static TestCommand FromArgs(string[] args, string msbuildPath = null)
3232
{
3333
"/t:VSTest",
3434
"/v:quiet",
35+
"/nodereuse:false", // workaround for https://github.com/Microsoft/vstest/issues/1503
3536
"/nologo"
3637
};
3738

@@ -95,7 +96,23 @@ public static int Run(string[] args)
9596
return e.ExitCode;
9697
}
9798

98-
return cmd.Execute();
99+
// Workaround for https://github.com/Microsoft/vstest/issues/1503
100+
const string NodeWindowEnvironmentName = "MSBUILDENSURESTDOUTFORTASKPROCESSES";
101+
string previousNodeWindowSetting = Environment.GetEnvironmentVariable(NodeWindowEnvironmentName);
102+
103+
int result = -1;
104+
105+
try
106+
{
107+
Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, "1");
108+
result = cmd.Execute();
109+
}
110+
finally
111+
{
112+
Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, previousNodeWindowSetting);
113+
}
114+
115+
return result;
99116
}
100117

101118
private static string GetSemiColonEscapedString(string arg)

0 commit comments

Comments
 (0)