Read dotnet install location from DOTNET_ROOT instead of Registry
I manage my dotnet installs in usermode through the scoop package manager at %USERPROFILE%\scoop\apps\dotnet-sdk-preview\current. As a result, the DOTNET_ROOT environment variable is up-to-date but my registry key still points to Program Files. I could update this, but it would be more helpful to me if UnityRoslynUpdater at least had an option to obey DOTNET_ROOT.
I can take a look at implementing this later, or if you're interested in opening a pull request it should be as simple as changing GetCurrentInstallation in DotNetInstallation.cs to:
private static DotNetInstallation GetCurrentInstallation()
{
string? location = Environment.GetEnvironmentVariable("DOTNET_ROOT");
if (string.IsNullOrEmpty(location))
location = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\dotnet\Setup\InstalledVersions\x64", "InstallLocation", null) as string;
if (string.IsNullOrEmpty(location))
location = GetDefaultInstallationLocation();
return new DotNetInstallation(location);
}
Implemented in https://github.com/DaZombieKiller/UnityRoslynUpdater/commit/2ec52dc8d11b2a9990305bbda0b4fcc5271723ac
Thank you!