Skip to content

Commit

Permalink
skip duplicated packages with the packageId as name
Browse files Browse the repository at this point in the history
  • Loading branch information
cwuethrich committed Mar 7, 2024
1 parent e2c7e08 commit 6961854
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions source/Nuke.Tooling/NuGetPackageResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ private static IEnumerable<InstalledPackage> GetDependentPackages(InstalledPacka
.OrderByDescending(x => x.Version)
.ToList();

if (candidatePackages.GroupBy(g => g.Version).Any(p => p.Count() > 1))
// skip duplicated packages with the packageId as name
candidatePackages = candidatePackages
.GroupBy(g => g.Version)
.SelectMany(g => g.Count() <= 1 ? g : g.Where(p => !p.File.NameWithoutExtension.EqualsOrdinalIgnoreCase(packageId)))
.ToList();

return versionRange == null
? candidatePackages.FirstOrDefault()
: candidatePackages.SingleOrDefault(x => x.Version == versionRange.FindBestMatch(candidatePackages.Select(y => y.Version)));
Expand Down

0 comments on commit 6961854

Please sign in to comment.