Skip to content

Commit 5ce557e

Browse files
use SpecialFolder.UserProfile instead of USERPROFILE (#15135)
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
1 parent 4e3c44c commit 5ce557e

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/Microsoft.Extensions.DependencyModel/Resolution/PackageCompilationAssemblyResolver.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,13 @@ internal static string[] GetDefaultProbeDirectories(Platform osPlatform, IEnviro
5656
return new string[] { packageDirectory };
5757
}
5858

59-
string basePath;
60-
if (osPlatform == Platform.Windows)
61-
{
62-
basePath = environment.GetEnvironmentVariable("USERPROFILE");
63-
}
64-
else
65-
{
66-
basePath = environment.GetEnvironmentVariable("HOME");
67-
}
68-
59+
string basePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
6960
if (string.IsNullOrEmpty(basePath))
7061
{
7162
return new string[] { string.Empty };
7263
}
7364

7465
return new string[] { Path.Combine(basePath, ".nuget", "packages") };
75-
7666
}
7767

7868
public bool TryResolveAssemblyPaths(CompilationLibrary library, List<string> assemblies)

src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/XunitPackageCompilationAssemblyResolver.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ static List<string> GetDefaultProbeDirectories(Platform osPlatform, IMessageSink
4444
results.Add(packageDirectory);
4545
else
4646
{
47-
string basePath;
48-
if (osPlatform == Platform.Windows)
49-
basePath = Environment.GetEnvironmentVariable("USERPROFILE");
50-
else
51-
basePath = Environment.GetEnvironmentVariable("HOME");
52-
47+
string basePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
5348
if (!string.IsNullOrEmpty(basePath))
5449
results.Add(Path.Combine(basePath, ".nuget", "packages"));
5550
}

0 commit comments

Comments
 (0)