From 714880b3f345fc33f183e2cf06c6520e38398cb4 Mon Sep 17 00:00:00 2001 From: Alexandr Morogov <42555001+krankenbro@users.noreply.github.com> Date: Mon, 16 Aug 2021 09:51:45 +0200 Subject: [PATCH] VCI-107: Fix version downgrade issue (#12) --- PlatformTools/Build.PackageManager.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/PlatformTools/Build.PackageManager.cs b/PlatformTools/Build.PackageManager.cs index d1635ec..81213db 100644 --- a/PlatformTools/Build.PackageManager.cs +++ b/PlatformTools/Build.PackageManager.cs @@ -69,9 +69,9 @@ internal partial class Build continue; } - if (!string.IsNullOrEmpty(module.Version) && externalModule.Version.CompareTo(module.Version) > 0) + if (!string.IsNullOrEmpty(module.Version) && externalModule.Version < new SemanticVersion(new Version(module.Version))) { - Logger.Error($"The latest available version of module ${module.Id} is ${externalModule.Version}, but entered: ${module.Version}"); + Logger.Error($"The latest available version of module {module.Id} is {externalModule.Version}, but entered: {module.Version}"); continue; } @@ -202,6 +202,7 @@ private bool NeedToInstallPlatform(string version) var externalModuleCatalog = ExtModuleCatalog.GetCatalog(GitHubToken, localModuleCatalog, packageManifest.ModuleSources); var moduleInstaller = ModuleInstallerFacade.GetModuleInstaller(discoveryPath, ProbingPath, GitHubToken, packageManifest.ModuleSources); var modulesToInstall = new List(); + var alreadyInstalledModules = localModuleCatalog.Modules.OfType().Where(m => m.IsInstalled); foreach (var module in packageManifest.Modules) { @@ -212,7 +213,7 @@ private bool NeedToInstallPlatform(string version) ControlFlow.Fail($"No module {module.Id} found"); } - if (externalModule.IsInstalled && externalModule.Version.ToString() == module.Version) + if (alreadyInstalledModules.Any(installedModule => installedModule.ModuleName == module.Id && installedModule.Version.ToString() == module.Version)) { continue; } @@ -261,10 +262,12 @@ private bool NeedToInstallPlatform(string version) if (!SkipDependencySolving) { var missingModules = externalModuleCatalog - .CompleteListWithDependencies(modulesToInstall.Where(m => !m.IsInstalled)) + .CompleteListWithDependencies(modulesToInstall) .Except(modulesToInstall) .OfType() + .Except(alreadyInstalledModules) .ToList(); + modulesToInstall.AddRange(missingModules); } modulesToInstall.ForEach(module =>