Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,13 @@ public static Stream TryOpenFile(string path)
/// </summary>
public static string GetDotNetHomeDirectory()
{
string dotnetHome;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
string basePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
if (!string.IsNullOrEmpty(basePath))
{
dotnetHome = Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE") ?? throw new ArgumentNullException("USERPROFILE environment variable not found"), ".dotnet");
throw new ArgumentNullException("UserProfile directory not found");
}
else
{
dotnetHome = Path.Combine(Environment.GetEnvironmentVariable("HOME") ?? throw new ArgumentNullException("HOME environment variable not found"), ".dotnet");
}
return dotnetHome;

return Path.Combine(basePath, ".dotnet");
}

/// <summary>
Expand Down
14 changes: 3 additions & 11 deletions src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,10 @@ private void ParseConfigFile(string path)
// This emulates that logic so the VS Test Explorer can still run the tests for
// config files that don't set the NugetPackagesCacheDir value (like the SOS unit
// tests).
string nugetPackagesRoot = null;
if (OS.Kind == OSKind.Windows)
string basePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
if (!string.IsNullOrEmpty(basePath))
{
nugetPackagesRoot = Environment.GetEnvironmentVariable("UserProfile");
}
else if (OS.Kind is OSKind.Linux or OSKind.OSX)
{
nugetPackagesRoot = Environment.GetEnvironmentVariable("HOME");
}
if (nugetPackagesRoot != null)
{
nugetPackages = Path.Combine(nugetPackagesRoot, ".nuget", "packages");
nugetPackages = Path.Combine(basePath, ".nuget", "packages");
}
}
// The TargetArchitecture and NuGetPackageCacheDir can still be overridden
Expand Down