Skip to content

Commit 14ac665

Browse files
committed
Merge pull request #209 from vosen/master
Fix #207
2 parents 611a605 + 05bd021 commit 14ac665

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

VisualRust.Shared/Environment.cs

+20-15
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ namespace VisualRust.Shared
1414
public class Environment
1515
{
1616
private const string InnoPath = @"Software\Microsoft\Windows\CurrentVersion\Uninstall\Rust_is1";
17-
private const string MozillaPath = @"Software\Mozilla Foundation";
17+
private static readonly string[] MozillaPaths = { @"Software\Mozilla Foundation", @"Software\The Rust Project Developers" };
1818
private const string install = "InstallLocation";
19-
19+
2020
public const string DefaultTarget = "default";
2121

2222
public static string FindInstallPath(string target)
@@ -49,7 +49,7 @@ public static IEnumerable<string> FindCurrentUserInstallPaths()
4949

5050
public static TargetTriple GetTarget(string exePath)
5151
{
52-
if(!File.Exists(exePath))
52+
if (!File.Exists(exePath))
5353
return null;
5454
ProcessStartInfo psi = new ProcessStartInfo
5555
{
@@ -65,7 +65,7 @@ public static TargetTriple GetTarget(string exePath)
6565
Process proc = Process.Start(psi);
6666
verboseVersion = proc.StandardOutput.ReadToEnd();
6767
}
68-
catch (Win32Exception)
68+
catch (Win32Exception)
6969
{
7070
return null;
7171
}
@@ -102,7 +102,7 @@ private static IEnumerable<string> GetAllInstallPaths()
102102
static string GetMultirustInstallRoot()
103103
{
104104
string multirustHome = System.Environment.GetEnvironmentVariable("MULTIRUST_HOME");
105-
if(String.IsNullOrEmpty(multirustHome))
105+
if (String.IsNullOrEmpty(multirustHome))
106106
{
107107
string localAppData = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
108108
return Path.Combine(localAppData, ".multirust");
@@ -123,15 +123,20 @@ private static string[] GetInnoInstallRoot()
123123

124124
private static IEnumerable<string> GetInstallRoots(RegistryHive hive, RegistryView view)
125125
{
126-
RegistryKey mozillaKey = RegistryKey.OpenBaseKey(hive, view).OpenSubKey(MozillaPath);
127-
if (mozillaKey == null)
128-
return new string[0];
129-
return mozillaKey
130-
.GetSubKeyNames()
131-
.Where(n => n.StartsWith("Rust", StringComparison.OrdinalIgnoreCase))
132-
.SelectMany(n => AllSubKeys(mozillaKey.OpenSubKey(n)))
133-
.Select(k => k.GetValue("InstallDir") as string)
134-
.Where(x => x != null);
126+
foreach (string root in MozillaPaths)
127+
{
128+
RegistryKey mozillaKey = RegistryKey.OpenBaseKey(hive, view).OpenSubKey(root);
129+
if (mozillaKey == null)
130+
continue;
131+
var paths = mozillaKey
132+
.GetSubKeyNames()
133+
.Where(n => n.StartsWith("Rust", StringComparison.OrdinalIgnoreCase))
134+
.SelectMany(n => AllSubKeys(mozillaKey.OpenSubKey(n)))
135+
.Select(k => k.GetValue("InstallDir") as string)
136+
.Where(x => x != null);
137+
foreach(string path in paths)
138+
yield return path;
139+
}
135140
}
136141

137142
private static IEnumerable<RegistryKey> AllSubKeys(RegistryKey key)
@@ -141,7 +146,7 @@ private static IEnumerable<RegistryKey> AllSubKeys(RegistryKey key)
141146

142147
private static bool CanBuildTarget(string exePath, string target)
143148
{
144-
if(!File.Exists(exePath))
149+
if (!File.Exists(exePath))
145150
return false;
146151
if (String.Equals(DefaultTarget, target, StringComparison.OrdinalIgnoreCase))
147152
return true;

0 commit comments

Comments
 (0)