public List <Model.PackageSet> ProcessAll(List <NugetDependency> packages) { foreach (NugetDependency package in packages) { Add(package.Name, package.Name, package.VersionRange, package.Framework); } var builder = new Model.PackageSetBuilder(); foreach (ResolutionData data in resolutionData.Values) { var deps = new HashSet <Model.PackageId>(); foreach (var dep in data.Dependencies.Keys) { if (!resolutionData.ContainsKey(dep)) { throw new Exception($"Encountered a dependency but was unable to resolve a package for it: {dep}"); } else { deps.Add(new Model.PackageId(resolutionData[dep].Name, resolutionData[dep].CurrentVersion.ToNormalizedString())); } } builder.AddOrUpdatePackage(new Model.PackageId(data.Name, data.CurrentVersion.ToNormalizedString()), deps); } return(builder.GetPackageList()); }
public DependencyResult Process() { var builder = new Model.PackageSetBuilder(); var result = new DependencyResult(); foreach (var target in LockFile.Targets) { foreach (var library in target.Libraries) { string name = library.Name; string version = library.Version.ToNormalizedString(); var packageId = new Model.PackageId(name, version); HashSet <Model.PackageId> dependencies = new HashSet <Model.PackageId>(); foreach (var dep in library.Dependencies) { var id = dep.Id; var vr = dep.VersionRange; //vr.Float.FloatBehavior = NuGet.Versioning.NuGetVersionFloatBehavior. var lb = target.Libraries; var bs = BestVersion(id, vr, lb); if (bs == null) { Console.WriteLine(dep.Id); bs = BestVersion(id, vr, lb); } else { var depId = new Model.PackageId(id, bs.ToNormalizedString()); dependencies.Add(depId); } } builder.AddOrUpdatePackage(packageId, dependencies); } } if (LockFile.PackageSpec.Dependencies.Count != 0) { foreach (var dep in LockFile.PackageSpec.Dependencies) { var version = builder.GetBestVersion(dep.Name, dep.LibraryRange.VersionRange); result.Dependencies.Add(new Model.PackageId(dep.Name, version)); } } else { foreach (var framework in LockFile.PackageSpec.TargetFrameworks) { foreach (var dep in framework.Dependencies) { var version = builder.GetBestVersion(dep.Name, dep.LibraryRange.VersionRange); result.Dependencies.Add(new Model.PackageId(dep.Name, version)); } } } if (result.Dependencies.Count == 0) { Console.WriteLine("Found no dependencies for lock file: " + LockFile.Path); } result.Packages = builder.GetPackageList(); return(result); }