diff --git a/Util/DotNetUtil.cs b/Util/DotNetUtil.cs index f201a3732a..4a0aec6009 100644 --- a/Util/DotNetUtil.cs +++ b/Util/DotNetUtil.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -47,6 +47,11 @@ namespace Cli.FunctionalTests.Util private static readonly HttpClient _httpClient = new HttpClient(); + private static readonly IEnumerable> _globalEnvironment = new KeyValuePair[] { + // Ignore globally-installed .NET Core components + new KeyValuePair("DOTNET_MULTILEVEL_LOOKUP", "false"), + }; + private static (SemanticVersion SdkVersion, SemanticVersion RuntimeVersion) GetVersions() { var info = RunDotNet("--info", workingDirectory: null); @@ -151,7 +156,8 @@ namespace Cli.FunctionalTests.Util private static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) StartDotNet( string arguments, string workingDirectory, IEnumerable> environment = null) { - return StartProcess("dotnet", arguments, workingDirectory, environment); + var env = _globalEnvironment.Concat(environment ?? Enumerable.Empty>()); + return StartProcess("dotnet", arguments, workingDirectory, env); } private static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) StartProcess(