Skip to content

Commit

Permalink
VCI-107: Fix version downgrade issue (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
krankenbro authored Aug 16, 2021
1 parent c6d6ddc commit 714880b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions PlatformTools/Build.PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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<ManifestModuleInfo>();
var alreadyInstalledModules = localModuleCatalog.Modules.OfType<ManifestModuleInfo>().Where(m => m.IsInstalled);

foreach (var module in packageManifest.Modules)
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -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<ManifestModuleInfo>()
.Except(alreadyInstalledModules)
.ToList();

modulesToInstall.AddRange(missingModules);
}
modulesToInstall.ForEach(module =>
Expand Down

0 comments on commit 714880b

Please sign in to comment.