Skip to content

Commit 8e3d1f9

Browse files
authored
Ignore globally-installed .NET Core components (#18)
1 parent 941d94c commit 8e3d1f9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Util/DotNetUtil.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -47,6 +47,11 @@ internal static class DotNetUtil
4747

4848
private static readonly HttpClient _httpClient = new HttpClient();
4949

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+
5055
private static (SemanticVersion SdkVersion, SemanticVersion RuntimeVersion) GetVersions()
5156
{
5257
var info = RunDotNet("--info", workingDirectory: null);
@@ -151,7 +156,8 @@ private static string RunDotNet(string arguments, string workingDirectory,
151156
private static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) StartDotNet(
152157
string arguments, string workingDirectory, IEnumerable<KeyValuePair<string, string>> environment = null)
153158
{
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);
155161
}
156162

157163
private static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) StartProcess(

0 commit comments

Comments
 (0)