|
1 |
| -// Copyright (c) .NET Foundation. All rights reserved. |
| 1 | +// Copyright (c) .NET Foundation. All rights reserved. |
2 | 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
3 | 3 |
|
4 | 4 | using System;
|
@@ -47,6 +47,11 @@ internal static class DotNetUtil
|
47 | 47 |
|
48 | 48 | private static readonly HttpClient _httpClient = new HttpClient();
|
49 | 49 |
|
| 50 | + private static readonly IEnumerable<KeyValuePair<string, string>> _globalEnvironment = new KeyValuePair<string, string>[] { |
| 51 | + // Ignore globally-installed .NET Core components |
| 52 | + new KeyValuePair<string, string>("DOTNET_MULTILEVEL_LOOKUP", "false"), |
| 53 | + }; |
| 54 | + |
50 | 55 | private static (SemanticVersion SdkVersion, SemanticVersion RuntimeVersion) GetVersions()
|
51 | 56 | {
|
52 | 57 | var info = RunDotNet("--info", workingDirectory: null);
|
@@ -151,7 +156,8 @@ private static string RunDotNet(string arguments, string workingDirectory,
|
151 | 156 | private static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) StartDotNet(
|
152 | 157 | string arguments, string workingDirectory, IEnumerable<KeyValuePair<string, string>> environment = null)
|
153 | 158 | {
|
154 |
| - return StartProcess("dotnet", arguments, workingDirectory, environment); |
| 159 | + var env = _globalEnvironment.Concat(environment ?? Enumerable.Empty<KeyValuePair<string, string>>()); |
| 160 | + return StartProcess("dotnet", arguments, workingDirectory, env); |
155 | 161 | }
|
156 | 162 |
|
157 | 163 | private static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) StartProcess(
|
|
0 commit comments