From aa8433973d8150a7d4ac9bda789ea14b1bd3365c Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Fri, 4 Oct 2024 21:56:09 +0300 Subject: [PATCH 1/2] use SpecialFolder.UserProfile instead of USERPROFILE --- .../XunitPackageCompilationAssemblyResolver.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/XunitPackageCompilationAssemblyResolver.cs b/src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/XunitPackageCompilationAssemblyResolver.cs index 56015598f02..819a1491dee 100644 --- a/src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/XunitPackageCompilationAssemblyResolver.cs +++ b/src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/XunitPackageCompilationAssemblyResolver.cs @@ -44,12 +44,7 @@ static List GetDefaultProbeDirectories(Platform osPlatform, IMessageSink results.Add(packageDirectory); else { - string basePath; - if (osPlatform == Platform.Windows) - basePath = Environment.GetEnvironmentVariable("USERPROFILE"); - else - basePath = Environment.GetEnvironmentVariable("HOME"); - + string basePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); if (!string.IsNullOrEmpty(basePath)) results.Add(Path.Combine(basePath, ".nuget", "packages")); } From 1cb445f19522423aef429b16fe98d36b34e62aaf Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Fri, 4 Oct 2024 21:58:08 +0300 Subject: [PATCH 2/2] userprofile --- .../Resolution/PackageCompilationAssemblyResolver.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/Microsoft.Extensions.DependencyModel/Resolution/PackageCompilationAssemblyResolver.cs b/src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/Microsoft.Extensions.DependencyModel/Resolution/PackageCompilationAssemblyResolver.cs index 975dc6adada..1fe0d1b62ee 100644 --- a/src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/Microsoft.Extensions.DependencyModel/Resolution/PackageCompilationAssemblyResolver.cs +++ b/src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/Microsoft.Extensions.DependencyModel/Resolution/PackageCompilationAssemblyResolver.cs @@ -56,23 +56,13 @@ internal static string[] GetDefaultProbeDirectories(Platform osPlatform, IEnviro return new string[] { packageDirectory }; } - string basePath; - if (osPlatform == Platform.Windows) - { - basePath = environment.GetEnvironmentVariable("USERPROFILE"); - } - else - { - basePath = environment.GetEnvironmentVariable("HOME"); - } - + string basePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); if (string.IsNullOrEmpty(basePath)) { return new string[] { string.Empty }; } return new string[] { Path.Combine(basePath, ".nuget", "packages") }; - } public bool TryResolveAssemblyPaths(CompilationLibrary library, List assemblies)