コード例 #1
0
        internal static RiderInfo[] GetAllFoundInfos(OperatingSystemFamilyRider operatingSystemFamily)
        {
            try
            {
                switch (operatingSystemFamily)
                {
                case OperatingSystemFamilyRider.Windows:
                {
                    return(CollectRiderInfosWindows());
                }

                case OperatingSystemFamilyRider.MacOSX:
                {
                    return(CollectRiderInfosMac());
                }

                case OperatingSystemFamilyRider.Linux:
                {
                    return(CollectAllRiderPathsLinux());
                }
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(new RiderInfo[0]);
        }
コード例 #2
0
        private static string[] GetAllRiderPaths(OperatingSystemFamilyRider operatingSystemFamily)
        {
            switch (operatingSystemFamily)
            {
            case OperatingSystemFamilyRider.Windows:
            {
                string[] folders =
                {
                    @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains", Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                        @"Microsoft\Windows\Start Menu\Programs\JetBrains Toolbox")
                };

                var newPathLnks = folders.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                                  .SelectMany(c => c.GetFiles("*Rider*.lnk")).ToArray();
                if (newPathLnks.Any())
                {
                    var results = newPathLnks
                                  .Select(newPathLnk => new FileInfo(ShortcutResolver.Resolve(newPathLnk.FullName)))
                                  .Where(fi => File.Exists(fi.FullName))
                                  .ToArray()
                                  .OrderByDescending(fi => FileVersionInfo.GetVersionInfo(fi.FullName).ProductVersion)
                                  .Select(a => a.FullName).ToArray();

                    return(results);
                }
            }
            break;

            case OperatingSystemFamilyRider.MacOSX:
            {
                // "/Applications/*Rider*.app"
                //"~/Applications/JetBrains Toolbox/*Rider*.app"
                string[] folders =
                {
                    "/Applications", Path.Combine(Environment.GetEnvironmentVariable("HOME"), "Applications/JetBrains Toolbox")
                };
                var results = folders.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                              .SelectMany(c => c.GetDirectories("*Rider*.app"))
                              .Select(a => a.FullName).ToArray();
                return(results);
            }

            case OperatingSystemFamilyRider.Linux:
            {
                var home = Environment.GetEnvironmentVariable("HOME");
                if (string.IsNullOrEmpty(home))
                {
                    return(new string[0]);
                }
                //$Home/.local/share/JetBrains/Toolbox/apps/Rider/ch-0/173.3994.1125/bin/rider.sh
                var riderPath = Path.Combine(home, @".local/share/JetBrains/Toolbox/apps/Rider");
                var results   = Directory.GetDirectories(riderPath).SelectMany(Directory.GetDirectories).Select(b => Path.Combine(b, "bin/rider.sh")).Where(File.Exists).ToArray();
                return(results);
            }
            }

            return(new string[0]);
        }
コード例 #3
0
        internal static bool RiderPathExist(string path, OperatingSystemFamilyRider operatingSystemFamilyRider)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }
            // windows or mac
            var fileInfo = new FileInfo(path);

            if (!fileInfo.Name.ToLower().Contains("rider"))
            {
                return(false);
            }
            var directoryInfo = new DirectoryInfo(path);
            var isMac         = operatingSystemFamilyRider == OperatingSystemFamilyRider.MacOSX;

            return(fileInfo.Exists || (isMac && directoryInfo.Exists));
        }
コード例 #4
0
 internal static string[] GetAllFoundPaths(OperatingSystemFamilyRider operatingSystemFamily)
 {
     return(GetAllFoundInfos(operatingSystemFamily).Select(a => a.Path).ToArray());
 }
コード例 #5
0
 internal static string[] GetAllFoundPaths(OperatingSystemFamilyRider operatingSystemFamily)
 {
     // fix separators
     return(GetAllRiderPaths(operatingSystemFamily).Select(a => new FileInfo(a).FullName).ToArray());
 }
コード例 #6
0
        private static string[] GetAllRiderPaths(OperatingSystemFamilyRider operatingSystemFamily)
        {
            switch (operatingSystemFamily)
            {
            case OperatingSystemFamilyRider.Windows:
            {
                string[] folders =
                {
                    @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains", Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                        @"Microsoft\Windows\Start Menu\Programs\JetBrains Toolbox")
                };

                var newPathLnks = folders.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                                  .SelectMany(c => c.GetFiles("*Rider*.lnk")).ToArray();
                if (newPathLnks.Any())
                {
                    var results = newPathLnks
                                  .Select(newPathLnk => new FileInfo(ShortcutResolver.Resolve(newPathLnk.FullName)))
                                  .Where(fi => File.Exists(fi.FullName))
                                  .ToArray()
                                  .OrderByDescending(fi => FileVersionInfo.GetVersionInfo(fi.FullName).ProductVersion)
                                  .Select(a => a.FullName).ToArray();

                    return(results);
                }
            }
            break;

            case OperatingSystemFamilyRider.MacOSX:
            {
                // "/Applications/*Rider*.app"
                //"~/Applications/JetBrains Toolbox/*Rider*.app"
                string[] folders =
                {
                    "/Applications", Path.Combine(Environment.GetEnvironmentVariable("HOME"), "Applications/JetBrains Toolbox")
                };
                var results = folders.Select(b => new DirectoryInfo(b)).Where(a => a.Exists)
                              .SelectMany(c => c.GetDirectories("*Rider*.app"))
                              .Select(a => a.FullName).ToArray();
                return(results);
            }

            case OperatingSystemFamilyRider.Linux:
            {
                var home = Environment.GetEnvironmentVariable("HOME");
                if (string.IsNullOrEmpty(home))
                {
                    return(new string[0]);
                }
                //$Home/.local/share/JetBrains/Toolbox/apps/Rider/ch-0/173.3994.1125/bin/rider.sh
                //$Home/.local/share/JetBrains/Toolbox/apps/Rider/ch-0/.channel.settings.json
                var riderPath    = Path.Combine(home, @".local/share/JetBrains/Toolbox/apps/Rider");
                var channelFiles = Directory.GetDirectories(riderPath)
                                   .Select(b => Path.Combine(b, ".channel.settings.json")).Where(File.Exists).ToArray();

                var paths = channelFiles.Select(a =>
                    {
                        try
                        {
                            var channelDir = Path.GetDirectoryName(a);
                            var json       = File.ReadAllText(a);
                            var data       = (JObject)JsonConvert.DeserializeObject(json);
                            var builds     = data["active-application"]["builds"];
                            if (builds.HasValues)
                            {
                                var build = builds.First;
                                return(Path.Combine(Path.Combine(channelDir, build.Value <string>()), @"bin/rider.sh"));
                            }
                        }
                        catch (Exception e)
                        {
                            ourLogger.Warn(e, "Failed to get RiderPath via .channel.settings.json");
                        }
                        return(null);
                    })
                            .Where(c => !string.IsNullOrEmpty(c))
                            .ToArray();
                if (!paths.Any())
                {
                    return(Directory.GetDirectories(riderPath).SelectMany(Directory.GetDirectories).Select(b => Path.Combine(b, "bin/rider.sh")).Where(File.Exists).ToArray());
                }
                return(paths);
            }
            }

            return(new string[0]);
        }