On Windows find Rider installed for CurrentUser

(cherry picked from commit c95e20a089)
This commit is contained in:
Ivan Shakhov 2020-02-28 21:34:20 +01:00 committed by Rémi Verschelde
parent fa60e77964
commit 88f0cd0b27
1 changed files with 20 additions and 11 deletions

View File

@ -218,20 +218,29 @@ namespace GodotTools.Ides.Rider
private static void CollectPathsFromRegistry(string registryKey, List<string> installPaths) private static void CollectPathsFromRegistry(string registryKey, List<string> installPaths)
{ {
using (var key = Registry.CurrentUser.OpenSubKey(registryKey))
{
CollectPathsFromRegistry(installPaths, key);
}
using (var key = Registry.LocalMachine.OpenSubKey(registryKey)) using (var key = Registry.LocalMachine.OpenSubKey(registryKey))
{ {
if (key == null) return; CollectPathsFromRegistry(installPaths, key);
foreach (var subkeyName in key.GetSubKeyNames().Where(a => a.Contains("Rider"))) }
}
private static void CollectPathsFromRegistry(List<string> installPaths, RegistryKey key)
{
if (key == null) return;
foreach (var subkeyName in key.GetSubKeyNames().Where(a => a.Contains("Rider")))
{
using (var subkey = key.OpenSubKey(subkeyName))
{ {
using (var subkey = key.OpenSubKey(subkeyName)) var folderObject = subkey?.GetValue("InstallLocation");
{ if (folderObject == null) continue;
var folderObject = subkey?.GetValue("InstallLocation"); var folder = folderObject.ToString();
if (folderObject == null) continue; var possiblePath = Path.Combine(folder, @"bin\rider64.exe");
var folder = folderObject.ToString(); if (File.Exists(possiblePath))
var possiblePath = Path.Combine(folder, @"bin\rider64.exe"); installPaths.Add(possiblePath);
if (File.Exists(possiblePath))
installPaths.Add(possiblePath);
}
} }
} }
} }