From 2e9deba0b52490f2b7e8cee1637873ed161d294c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Wed, 2 Jul 2025 14:56:59 +0200 Subject: [PATCH 1/4] Fix forwarding dotnet_root --- src/Cli/dotnet/Commands/Test/TestCommand.cs | 15 +++-- .../Commands/Test/VSTestForwardingApp.cs | 60 ++++++++++++++++--- .../dotnet/Commands/VSTest/VSTestCommand.cs | 3 +- src/Cli/dotnet/Parser.cs | 2 +- .../MSBuild/GivenDotnetVsTestForwardingApp.cs | 4 +- 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/src/Cli/dotnet/Commands/Test/TestCommand.cs b/src/Cli/dotnet/Commands/Test/TestCommand.cs index 4879f7a62fe3..24ad6f7a58da 100644 --- a/src/Cli/dotnet/Commands/Test/TestCommand.cs +++ b/src/Cli/dotnet/Commands/Test/TestCommand.cs @@ -144,7 +144,9 @@ private static int ForwardToVSTestConsole(ParseResult parseResult, string[] args convertedArgs.Add($"--testSessionCorrelationId:{testSessionCorrelationId}"); } - int exitCode = new VSTestForwardingApp(convertedArgs).Execute(); + string archArg = parseResult.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; + + int exitCode = new VSTestForwardingApp(convertedArgs, archArg).Execute(); // We run post processing also if execution is failed for possible partial successful result to post process. exitCode |= RunArtifactPostProcessingIfNeeded(testSessionCorrelationId, parseResult, FeatureFlag.Instance); @@ -235,10 +237,11 @@ private static TestCommand FromParseResult(ParseResult result, string[] settings } } - // Set DOTNET_PATH if it isn't already set in the environment as it is required + // Set DOTNET_ROOT if it isn't already set in the environment as it is required // by the testhost which uses the apphost feature (Windows only). - (bool hasRootVariable, string rootVariableName, string rootValue) = VSTestForwardingApp.GetRootVariable(); - if (!hasRootVariable) + string archArg = result.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; + (bool setRootVariable, string rootVariableName, string rootValue) = VSTestForwardingApp.GetRootVariable(archArg); + if (!setRootVariable) { testCommand.EnvironmentVariable(rootVariableName, rootValue); VSTestTrace.SafeWriteTrace(() => $"Root variable set {rootVariableName}:{rootValue}"); @@ -272,9 +275,11 @@ internal static int RunArtifactPostProcessingIfNeeded(string testSessionCorrelat artifactsPostProcessArgs.Add($"--diag:{parseResult.GetValue(TestCommandParser.DiagOption)}"); } + string archArg = parseResult.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; + try { - return new VSTestForwardingApp(artifactsPostProcessArgs).Execute(); + return new VSTestForwardingApp(artifactsPostProcessArgs, archArg).Execute(); } finally { diff --git a/src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs b/src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs index b8c25c009dce..6feb3c929677 100644 --- a/src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs +++ b/src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs @@ -3,6 +3,7 @@ #nullable disable +using System.Reflection; using Microsoft.DotNet.Cli.Utils; namespace Microsoft.DotNet.Cli.Commands.Test; @@ -11,11 +12,11 @@ public class VSTestForwardingApp : ForwardingApp { private const string VstestAppName = "vstest.console.dll"; - public VSTestForwardingApp(IEnumerable argsToForward) + public VSTestForwardingApp(IEnumerable argsToForward, string targetArchitecture) : base(GetVSTestExePath(), argsToForward) { - (bool hasRootVariable, string rootVariableName, string rootValue) = GetRootVariable(); - if (!hasRootVariable) + (bool setRootVariable, string rootVariableName, string rootValue) = GetRootVariable(targetArchitecture); + if (!setRootVariable) { WithEnvironmentVariable(rootVariableName, rootValue); VSTestTrace.SafeWriteTrace(() => $"Root variable set {rootVariableName}:{rootValue}"); @@ -38,14 +39,57 @@ private static string GetVSTestExePath() return Path.Combine(AppContext.BaseDirectory, VstestAppName); } - internal static (bool hasRootVariable, string rootVariableName, string rootValue) GetRootVariable() + internal static (bool setRootVariable, string rootVariableName, string rootValue) GetRootVariable(string targetArchitecture) { - string rootVariableName = Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)"; - bool hasRootVariable = Environment.GetEnvironmentVariable(rootVariableName) != null; - string rootValue = hasRootVariable ? null : Path.GetDirectoryName(new Muxer().MuxerPath); + string[] rootVariables = []; + var processArchitecture = RuntimeInformation.ProcessArchitecture; + if (string.IsNullOrWhiteSpace(targetArchitecture) || processArchitecture != Enum.Parse(targetArchitecture, ignoreCase: true)) + { + // User specified the --arch parameter but it is different from current process architecture, so we won't set anything + // to not break child processes by setting DOTNET_ROOT on them; + return (setRootVariable: false, null, null); + } + + // Get variables to pick up from the current environment in the order in which they are inspected by the process. + rootVariables = GetRootVariablesToInspect(processArchitecture); + + string rootPath = null; + foreach (var variable in rootVariables) + { + rootPath = Environment.GetEnvironmentVariable(variable); + if (!string.IsNullOrWhiteSpace(rootPath)) + { + break; + } + } + + if (!string.IsNullOrWhiteSpace(rootPath)) + { + // Root path for this process was already set externally don't do anything. + return (setRootVariable: false, null, null); + } + + // VSTest only accepts the two variants below, and the apphost does fallback to DOTNET_ROOT in all architectures, so we pass the + // architecture non-specific env variable. + string rootVariableName = Environment.Is64BitProcess ? "VSTEST_WINAPPHOST_DOTNET_ROOT" : "VSTEST_WINAPPHOST_DOTNET_ROOT(x86)"; // We rename env variable to support --arch switch that relies on DOTNET_ROOT/DOTNET_ROOT(x86) // We provide VSTEST_WINAPPHOST_ only in case of testhost*.exe removing VSTEST_WINAPPHOST_ prefix and passing as env vars. - return (hasRootVariable, $"VSTEST_WINAPPHOST_{rootVariableName}", rootValue); + return (setRootVariable: true, rootVariableName, rootPath); + + static string[] GetRootVariablesToInspect(Architecture processArchitecture) + { + switch (processArchitecture) + { + case Architecture.X86: + return ["DOTNET_ROOT_X86", "DOTNET_ROOT(x86)"]; + + case Architecture.X64: + return ["DOTNET_ROOT_X64", "DOTNET_ROOT"]; + + default: + return [$"DOTNET_ROOT_{processArchitecture.ToString().ToUpperInvariant()}"]; + } + } } } diff --git a/src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs b/src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs index 9edcc2e6a162..c224bd22df40 100644 --- a/src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs +++ b/src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs @@ -29,7 +29,8 @@ public static int Run(ParseResult parseResult) args.Add($"--testSessionCorrelationId:{testSessionCorrelationId}"); } - VSTestForwardingApp vsTestforwardingApp = new(args); + string archArg = parseResult.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; + VSTestForwardingApp vsTestforwardingApp = new(args, archArg); int exitCode = vsTestforwardingApp.Execute(); diff --git a/src/Cli/dotnet/Parser.cs b/src/Cli/dotnet/Parser.cs index ec6bff87d7e9..476e35fca487 100644 --- a/src/Cli/dotnet/Parser.cs +++ b/src/Cli/dotnet/Parser.cs @@ -341,7 +341,7 @@ public override void Write(HelpContext context) } else if (command.Name.Equals(VSTestCommandParser.GetCommand().Name)) { - new VSTestForwardingApp(helpArgs).Execute(); + new VSTestForwardingApp(helpArgs, targetArchitecture: null).Execute(); } else if (command.Name.Equals(FormatCommandParser.GetCommand().Name)) { diff --git a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetVsTestForwardingApp.cs b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetVsTestForwardingApp.cs index 252e4a0af7b2..e7cc89d34bae 100644 --- a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetVsTestForwardingApp.cs +++ b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetVsTestForwardingApp.cs @@ -10,7 +10,7 @@ public class GivenDotnetVsTestForwardingApp [Fact] public void ItRunsVsTestApp() { - new VSTestForwardingApp(new string[0]) + new VSTestForwardingApp([], targetArchitecture: null) .GetProcessStartInfo().Arguments.Should().EndWith("vstest.console.dll"); } @@ -23,7 +23,7 @@ public void ItCanUseEnvironmentVariableToForceCustomPathToVsTestApp() try { Environment.SetEnvironmentVariable(vsTestConsolePath, dummyPath); - new VSTestForwardingApp(new string[0]) + new VSTestForwardingApp([], targetArchitecture: null) .GetProcessStartInfo().Arguments.Should().EndWith("vstest.custom.console.dll"); } finally From 89057dfd3b08a14284defe131846473202c90087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Wed, 2 Jul 2025 17:21:17 +0200 Subject: [PATCH 2/4] nullability decided to work? --- src/Cli/dotnet/Commands/Test/TestCommand.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cli/dotnet/Commands/Test/TestCommand.cs b/src/Cli/dotnet/Commands/Test/TestCommand.cs index 15010cef87a5..8086165acee6 100644 --- a/src/Cli/dotnet/Commands/Test/TestCommand.cs +++ b/src/Cli/dotnet/Commands/Test/TestCommand.cs @@ -144,7 +144,7 @@ private static int ForwardToVSTestConsole(ParseResult parseResult, string[] args convertedArgs.Add($"--testSessionCorrelationId:{testSessionCorrelationId}"); } - string archArg = parseResult.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; + string? archArg = parseResult.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; int exitCode = new VSTestForwardingApp(convertedArgs, archArg).Execute(); @@ -244,7 +244,7 @@ private static TestCommand FromParseResult(ParseResult result, string[] settings // Set DOTNET_ROOT if it isn't already set in the environment as it is required // by the testhost which uses the apphost feature (Windows only). - string archArg = result.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; + string? archArg = result.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; (bool setRootVariable, string rootVariableName, string rootValue) = VSTestForwardingApp.GetRootVariable(archArg); if (!setRootVariable) { @@ -280,7 +280,7 @@ internal static int RunArtifactPostProcessingIfNeeded(string testSessionCorrelat artifactsPostProcessArgs.Add($"--diag:{parseResult.GetValue(TestCommandParser.DiagOption)}"); } - string archArg = parseResult.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; + string? archArg = parseResult.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; try { From f5338c50d8770ee505e5e966e996d6d80dfbc578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Thu, 3 Jul 2025 15:34:40 +0200 Subject: [PATCH 3/4] Fix forwarding dotnet_root --- src/Cli/dotnet/Commands/Test/TestCommand.cs | 17 ++--- .../Commands/Test/VSTestForwardingApp.cs | 69 ++++--------------- .../dotnet/Commands/VSTest/VSTestCommand.cs | 3 +- src/Cli/dotnet/Parser.cs | 2 +- .../MSBuild/GivenDotnetVsTestForwardingApp.cs | 4 +- 5 files changed, 23 insertions(+), 72 deletions(-) diff --git a/src/Cli/dotnet/Commands/Test/TestCommand.cs b/src/Cli/dotnet/Commands/Test/TestCommand.cs index 8086165acee6..1430134f2eef 100644 --- a/src/Cli/dotnet/Commands/Test/TestCommand.cs +++ b/src/Cli/dotnet/Commands/Test/TestCommand.cs @@ -144,9 +144,7 @@ private static int ForwardToVSTestConsole(ParseResult parseResult, string[] args convertedArgs.Add($"--testSessionCorrelationId:{testSessionCorrelationId}"); } - string? archArg = parseResult.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; - - int exitCode = new VSTestForwardingApp(convertedArgs, archArg).Execute(); + int exitCode = new VSTestForwardingApp(convertedArgs).Execute(); // We run post processing also if execution is failed for possible partial successful result to post process. exitCode |= RunArtifactPostProcessingIfNeeded(testSessionCorrelationId, parseResult, FeatureFlag.Instance); @@ -242,12 +240,9 @@ private static TestCommand FromParseResult(ParseResult result, string[] settings } } - // Set DOTNET_ROOT if it isn't already set in the environment as it is required - // by the testhost which uses the apphost feature (Windows only). - string? archArg = result.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; - (bool setRootVariable, string rootVariableName, string rootValue) = VSTestForwardingApp.GetRootVariable(archArg); - if (!setRootVariable) - { + + Dictionary variables = VSTestForwardingApp.GetVSTestRootVariables(); + foreach (var (rootVariableName, rootValue) in variables) { testCommand.EnvironmentVariable(rootVariableName, rootValue); VSTestTrace.SafeWriteTrace(() => $"Root variable set {rootVariableName}:{rootValue}"); } @@ -280,11 +275,9 @@ internal static int RunArtifactPostProcessingIfNeeded(string testSessionCorrelat artifactsPostProcessArgs.Add($"--diag:{parseResult.GetValue(TestCommandParser.DiagOption)}"); } - string? archArg = parseResult.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; - try { - return new VSTestForwardingApp(artifactsPostProcessArgs, archArg).Execute(); + return new VSTestForwardingApp(artifactsPostProcessArgs).Execute(); } finally { diff --git a/src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs b/src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs index 6feb3c929677..fb81e15466f9 100644 --- a/src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs +++ b/src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs @@ -3,7 +3,6 @@ #nullable disable -using System.Reflection; using Microsoft.DotNet.Cli.Utils; namespace Microsoft.DotNet.Cli.Commands.Test; @@ -12,16 +11,16 @@ public class VSTestForwardingApp : ForwardingApp { private const string VstestAppName = "vstest.console.dll"; - public VSTestForwardingApp(IEnumerable argsToForward, string targetArchitecture) + public VSTestForwardingApp(IEnumerable argsToForward) : base(GetVSTestExePath(), argsToForward) { - (bool setRootVariable, string rootVariableName, string rootValue) = GetRootVariable(targetArchitecture); - if (!setRootVariable) + Dictionary variables = GetVSTestRootVariables(); + foreach (var (rootVariableName, rootValue) in variables) { WithEnvironmentVariable(rootVariableName, rootValue); VSTestTrace.SafeWriteTrace(() => $"Root variable set {rootVariableName}:{rootValue}"); } - + VSTestTrace.SafeWriteTrace(() => $"Forwarding to '{GetVSTestExePath()}' with args \"{argsToForward?.Aggregate((a, b) => $"{a} | {b}")}\""); } @@ -39,57 +38,17 @@ private static string GetVSTestExePath() return Path.Combine(AppContext.BaseDirectory, VstestAppName); } - internal static (bool setRootVariable, string rootVariableName, string rootValue) GetRootVariable(string targetArchitecture) + internal static Dictionary GetVSTestRootVariables() { - string[] rootVariables = []; - var processArchitecture = RuntimeInformation.ProcessArchitecture; - if (string.IsNullOrWhiteSpace(targetArchitecture) || processArchitecture != Enum.Parse(targetArchitecture, ignoreCase: true)) - { - // User specified the --arch parameter but it is different from current process architecture, so we won't set anything - // to not break child processes by setting DOTNET_ROOT on them; - return (setRootVariable: false, null, null); - } - - // Get variables to pick up from the current environment in the order in which they are inspected by the process. - rootVariables = GetRootVariablesToInspect(processArchitecture); - - string rootPath = null; - foreach (var variable in rootVariables) - { - rootPath = Environment.GetEnvironmentVariable(variable); - if (!string.IsNullOrWhiteSpace(rootPath)) - { - break; - } - } - - if (!string.IsNullOrWhiteSpace(rootPath)) + // Gather the current .NET SDK dotnet.exe location and forward it to vstest.console.dll so it can use it + // to setup DOTNET_ROOT for testhost.exe, to find the same installation of NET SDK that is running `dotnet test`. + // This way if we have private installation of .NET SDK, the testhost.exe will be able to use the same private installation. + // The way to set the environment is complicated and depends on the version of testhost, so we leave that implementation to vstest console, + // we just tell it where the current .net SDK is located, and what is the architecture of it. We don't have more information than that here. + return new() { - // Root path for this process was already set externally don't do anything. - return (setRootVariable: false, null, null); - } - - // VSTest only accepts the two variants below, and the apphost does fallback to DOTNET_ROOT in all architectures, so we pass the - // architecture non-specific env variable. - string rootVariableName = Environment.Is64BitProcess ? "VSTEST_WINAPPHOST_DOTNET_ROOT" : "VSTEST_WINAPPHOST_DOTNET_ROOT(x86)"; - - // We rename env variable to support --arch switch that relies on DOTNET_ROOT/DOTNET_ROOT(x86) - // We provide VSTEST_WINAPPHOST_ only in case of testhost*.exe removing VSTEST_WINAPPHOST_ prefix and passing as env vars. - return (setRootVariable: true, rootVariableName, rootPath); - - static string[] GetRootVariablesToInspect(Architecture processArchitecture) - { - switch (processArchitecture) - { - case Architecture.X86: - return ["DOTNET_ROOT_X86", "DOTNET_ROOT(x86)"]; - - case Architecture.X64: - return ["DOTNET_ROOT_X64", "DOTNET_ROOT"]; - - default: - return [$"DOTNET_ROOT_{processArchitecture.ToString().ToUpperInvariant()}"]; - } - } + ["VSTEST_DOTNET_ROOT_PATH"] = Path.GetDirectoryName(new Muxer().MuxerPath), + ["VSTEST_DOTNET_ROOT_ARCHITECTURE"] = RuntimeInformation.ProcessArchitecture.ToString() + }; } } diff --git a/src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs b/src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs index c224bd22df40..9edcc2e6a162 100644 --- a/src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs +++ b/src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs @@ -29,8 +29,7 @@ public static int Run(ParseResult parseResult) args.Add($"--testSessionCorrelationId:{testSessionCorrelationId}"); } - string archArg = parseResult.ForwardedOptionValues>(TestCommandParser.GetCommand(), "--arch")?.SingleOrDefault() ?? null; - VSTestForwardingApp vsTestforwardingApp = new(args, archArg); + VSTestForwardingApp vsTestforwardingApp = new(args); int exitCode = vsTestforwardingApp.Execute(); diff --git a/src/Cli/dotnet/Parser.cs b/src/Cli/dotnet/Parser.cs index 258eab2ac3d9..260c7dd3b82c 100644 --- a/src/Cli/dotnet/Parser.cs +++ b/src/Cli/dotnet/Parser.cs @@ -341,7 +341,7 @@ public override void Write(HelpContext context) } else if (command.Name.Equals(VSTestCommandParser.GetCommand().Name)) { - new VSTestForwardingApp(helpArgs, targetArchitecture: null).Execute(); + new VSTestForwardingApp(helpArgs).Execute(); } else if (command.Name.Equals(FormatCommandParser.GetCommand().Name)) { diff --git a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetVsTestForwardingApp.cs b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetVsTestForwardingApp.cs index e7cc89d34bae..252e4a0af7b2 100644 --- a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetVsTestForwardingApp.cs +++ b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetVsTestForwardingApp.cs @@ -10,7 +10,7 @@ public class GivenDotnetVsTestForwardingApp [Fact] public void ItRunsVsTestApp() { - new VSTestForwardingApp([], targetArchitecture: null) + new VSTestForwardingApp(new string[0]) .GetProcessStartInfo().Arguments.Should().EndWith("vstest.console.dll"); } @@ -23,7 +23,7 @@ public void ItCanUseEnvironmentVariableToForceCustomPathToVsTestApp() try { Environment.SetEnvironmentVariable(vsTestConsolePath, dummyPath); - new VSTestForwardingApp([], targetArchitecture: null) + new VSTestForwardingApp(new string[0]) .GetProcessStartInfo().Arguments.Should().EndWith("vstest.custom.console.dll"); } finally From f77d0fe59da4b53ead7cfee0c239f176f465c9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Thu, 17 Jul 2025 15:50:22 +0200 Subject: [PATCH 4/4] Fix tests checking dotnet_root forwarding --- .../VSTestForwardDotnetRootEnvironmentVariables/Tests.cs | 2 +- .../GivenDotnetTestForwardDotnetRootEnvironmentVariables.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/TestAssets/TestProjects/VSTestForwardDotnetRootEnvironmentVariables/Tests.cs b/test/TestAssets/TestProjects/VSTestForwardDotnetRootEnvironmentVariables/Tests.cs index 3de940ec7980..bd56746713c5 100644 --- a/test/TestAssets/TestProjects/VSTestForwardDotnetRootEnvironmentVariables/Tests.cs +++ b/test/TestAssets/TestProjects/VSTestForwardDotnetRootEnvironmentVariables/Tests.cs @@ -16,7 +16,7 @@ public void TestForwardDotnetRootEnvironmentVariables() // This project is compiled, and executed by the tests in "test/dotnet-test.Tests/GivenDotnetTestForwardDotnetRootEnvironmentVariables.cs" foreach (DictionaryEntry env in Environment.GetEnvironmentVariables()) { - if (env.Key.ToString().Contains("VSTEST_WINAPPHOST_")) + if (env.Key.ToString().Contains("VSTEST_")) { Console.WriteLine($"{env.Key.ToString()}={env.Value.ToString()}"); } diff --git a/test/dotnet.Tests/CommandTests/Test/GivenDotnetTestForwardDotnetRootEnvironmentVariables.cs b/test/dotnet.Tests/CommandTests/Test/GivenDotnetTestForwardDotnetRootEnvironmentVariables.cs index ec1c34a8d2dc..e7f6a68e8fbd 100644 --- a/test/dotnet.Tests/CommandTests/Test/GivenDotnetTestForwardDotnetRootEnvironmentVariables.cs +++ b/test/dotnet.Tests/CommandTests/Test/GivenDotnetTestForwardDotnetRootEnvironmentVariables.cs @@ -33,7 +33,8 @@ public void ShouldForwardDotnetRootEnvironmentVariablesIfNotProvided() .Should().Contain("Total tests: 1") .And.Contain("Passed: 1") .And.Contain("Passed TestForwardDotnetRootEnvironmentVariables") - .And.Contain("VSTEST_WINAPPHOST_"); + .And.Contain("VSTEST_DOTNET_ROOT_PATH") + .And.Contain("VSTEST_DOTNET_ROOT_ARCHITECTURE"); } result.ExitCode.Should().Be(0);