Beispiel #1
0
        private Tool GetLatestTool(ToolSettings toolSettings)
        {
            string[] zipPaths = Directory
                .EnumerateFiles(_settings.ZippedToolsDirectory, $"{toolSettings.Prefix}*.zip", SearchOption.TopDirectoryOnly)
                .ToArray();

            var versions = new List<Tool>();
            foreach (string zipPath in zipPaths)
            {
                string withoutExtension = Path.GetFileNameWithoutExtension(zipPath);
                string directoryPath = Path.Combine(_settings.ExtractedToolsDirectory, withoutExtension);
                string version = withoutExtension.Substring(toolSettings.Prefix.Length);
                Version parsedVersion;
                if (!Version.TryParse(version, out parsedVersion))
                {
                    continue;
                }

                versions.Add(new Tool
                {
                    Name = toolSettings.Name,
                    Settings = toolSettings,
                    ZipPath = zipPath,
                    DirectoryPath = directoryPath,
                    Version = version,
                    ExecutablePath = Path.Combine(directoryPath, toolSettings.ExecutablePath),
                    WorkingDirectory = Path.Combine(directoryPath, toolSettings.WorkingDirectory),
                    ConfigurationPath = Path.Combine(directoryPath, toolSettings.ConfigurationPath)
                });
            }

            if (versions.Count == 0)
            {
                return null;
            }

            return versions
                .OrderByDescending(t => Version.Parse(t.Version))
                .First();
        }
Beispiel #2
0
 private Tool Extract(ToolSettings toolSettings)
 {
     Tool tool = GetLatestTool(toolSettings);
     ExtractTool(tool, _settings.ReloadTools);
     return tool;
 }