Beispiel #1
0
        private static IDictionary <VisualStudioVersion, VisualStudioPath[]> GetInstalledVisualStudios()
        {
            Dictionary <VisualStudioVersion, VisualStudioPath[]> dictionary = new Dictionary <VisualStudioVersion, VisualStudioPath[]>();

            if (SyncVS.SolutionSynchronizationSettings.IsWindows)
            {
                IEnumerator enumerator = Enum.GetValues(typeof(VisualStudioVersion)).GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        VisualStudioVersion visualStudioVersion = (VisualStudioVersion)enumerator.Current;
                        if (visualStudioVersion <= VisualStudioVersion.VisualStudio2015)
                        {
                            try
                            {
                                string text = Environment.GetEnvironmentVariable(string.Format("VS{0}0COMNTOOLS", (int)visualStudioVersion));
                                if (!string.IsNullOrEmpty(text))
                                {
                                    string path = Paths.Combine(new string[]
                                    {
                                        text,
                                        "..",
                                        "IDE",
                                        "devenv.exe"
                                    });
                                    if (File.Exists(path))
                                    {
                                        dictionary[visualStudioVersion] = new VisualStudioPath[]
                                        {
                                            new VisualStudioPath(path, "")
                                        };
                                        continue;
                                    }
                                }
                                text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\{0}.0", (int)visualStudioVersion), "InstallDir");
                                if (string.IsNullOrEmpty(text))
                                {
                                    text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\{0}.0", (int)visualStudioVersion), "InstallDir");
                                }
                                if (!string.IsNullOrEmpty(text))
                                {
                                    string path2 = Paths.Combine(new string[]
                                    {
                                        text,
                                        "devenv.exe"
                                    });
                                    if (File.Exists(path2))
                                    {
                                        dictionary[visualStudioVersion] = new VisualStudioPath[]
                                        {
                                            new VisualStudioPath(path2, "")
                                        };
                                        continue;
                                    }
                                }
                                text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\{0}.0\\Debugger", (int)visualStudioVersion), "FEQARuntimeImplDll");
                                if (!string.IsNullOrEmpty(text))
                                {
                                    string text2 = SyncVS.DeriveVisualStudioPath(text);
                                    if (!string.IsNullOrEmpty(text2) && File.Exists(text2))
                                    {
                                        dictionary[visualStudioVersion] = new VisualStudioPath[]
                                        {
                                            new VisualStudioPath(SyncVS.DeriveVisualStudioPath(text), "")
                                        };
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
                string[] array = VisualStudioUtil.FindVisualStudioDevEnvPaths(15, "Microsoft.VisualStudio.Workload.ManagedGame");
                if (array != null && array.Length > 0)
                {
                    VisualStudioPath[] array2 = new VisualStudioPath[array.Length / 2];
                    for (int i = 0; i < array.Length / 2; i++)
                    {
                        array2[i] = new VisualStudioPath(array[i * 2], array[i * 2 + 1]);
                    }
                    dictionary[VisualStudioVersion.VisualStudio2017] = array2;
                }
            }
            return(dictionary);
        }
Beispiel #2
0
        private static IDictionary <VisualStudioVersion, string> GetInstalledVisualStudios()
        {
            Dictionary <VisualStudioVersion, string> dictionary = new Dictionary <VisualStudioVersion, string>();

            if (SyncVS.SolutionSynchronizationSettings.IsWindows)
            {
                IEnumerator enumerator = Enum.GetValues(typeof(VisualStudioVersion)).GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        VisualStudioVersion visualStudioVersion = (VisualStudioVersion)((int)enumerator.Current);
                        try
                        {
                            string text = Environment.GetEnvironmentVariable(string.Format("VS{0}0COMNTOOLS", (int)visualStudioVersion));
                            if (!string.IsNullOrEmpty(text))
                            {
                                string text2 = Paths.Combine(new string[]
                                {
                                    text,
                                    "..",
                                    "IDE",
                                    "devenv.exe"
                                });
                                if (File.Exists(text2))
                                {
                                    dictionary[visualStudioVersion] = text2;
                                    continue;
                                }
                            }
                            text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\{0}.0", (int)visualStudioVersion), "InstallDir");
                            if (string.IsNullOrEmpty(text))
                            {
                                text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\{0}.0", (int)visualStudioVersion), "InstallDir");
                            }
                            if (!string.IsNullOrEmpty(text))
                            {
                                string text3 = Paths.Combine(new string[]
                                {
                                    text,
                                    "devenv.exe"
                                });
                                if (File.Exists(text3))
                                {
                                    dictionary[visualStudioVersion] = text3;
                                    continue;
                                }
                            }
                            text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\{0}.0\\Debugger", (int)visualStudioVersion), "FEQARuntimeImplDll");
                            if (!string.IsNullOrEmpty(text))
                            {
                                string text4 = SyncVS.DeriveVisualStudioPath(text);
                                if (!string.IsNullOrEmpty(text4) && File.Exists(text4))
                                {
                                    dictionary[visualStudioVersion] = SyncVS.DeriveVisualStudioPath(text);
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
            return(dictionary);
        }