Example #1
0
 DependencyResolutionResult BuildResult(IPackageDescriptor packageDescriptor, LoggingPackageVisitor visitor, List <IPackageInfo> allPackages)
 {
     return(new DependencyResolutionResult(packageDescriptor,
                                           FromPacks(allPackages, visitor.Success).ToList(),
                                           FromPacks(allPackages, visitor.Fail).ToList(),
                                           FromNotFound(visitor.NotFound).ToList()));
 }
Example #2
0
        public DependencyResolutionResult TryResolveDependencies(IPackageDescriptor packageDescriptor, IEnumerable <IPackageRepository> repositoriesToQuery)
        {
            Debug.WriteLine("Resolving descriptor " + packageDescriptor.Dependencies.Select(x => x.ToString()).JoinString(", "));

            var excluded = new List <IPackageInfo>();

            var allPackages = repositoriesToQuery.Packages().SelectMany(_ => _).ToList();
            var notFound    = new List <PackageDependency>();

            for (int i = 0; i < MAX_RETRIES; i++)
            {
                var visitor = new LoggingPackageVisitor(
                    allPackages,
                    packages => Nuke(PackageStrategy.Latest(packages)),
                    fail: excluded);

                visitor.ReadDependency = LocalHints(packageDescriptor.Dependencies, Override(packageDescriptor.Overrides, visitor.ReadDependency));

                if (visitor.Visit(packageDescriptor.Dependencies))
                {
                    return(BuildResult(packageDescriptor, visitor, allPackages));
                }

                var hasNewIncompatibles = visitor.IncompatiblePackages.Except(excluded).Any();

                var currentNotFound = ReadNotFoundDependencies(visitor);
                var hasNewNotFound  = currentNotFound.Except(notFound).Any();
                if (!hasNewNotFound && !hasNewIncompatibles)
                {
                    return(BuildResult(packageDescriptor, visitor, allPackages));
                }
                excluded.AddRange(visitor.IncompatiblePackages);
                notFound = currentNotFound.ToList();
            }

            throw new InvalidOperationException(string.Format("OpenWrap tried {0} times to resolve the tree of dependencies and gave up.", MAX_RETRIES));
        }
Example #3
0
 static IEnumerable <PackageDependency> ReadNotFoundDependencies(LoggingPackageVisitor visitor)
 {
     return(visitor.NotFound.Select(_ => ((DependencyNode)_.Last()).Dependency));
 }