ResolveOperations() public method

public ResolveOperations ( IPackage package ) : IEnumerable
package IPackage
return IEnumerable
Exemplo n.º 1
0
        private void Uninstall(IPackage package, IDependentsResolver dependentsResolver, IPackageRepository repository)
        {
            // If we explicitly want to uninstall this package, then remove it from the retainment queue.
            _packagesToKeep.Remove(package);

            // If this package isn't part of the current graph (i.e. hasn't been visited yet) and
            // is marked for removal, then do nothing. This is so we don't get unnecessary duplicates.
            if (!Marker.Contains(package) && _operations.Contains(package, PackageAction.Uninstall))
            {
                return;
            }

            // Uninstall the conflicting package. We set throw on conflicts to false since we've
            // already decided that there were no conflicts based on the above code.
            var resolver = new UninstallWalker(
                repository,
                dependentsResolver,
                TargetFramework,
                NullLogger.Instance,
                removeDependencies: !IgnoreDependencies,
                forceRemove: false)
            {
                DisableWalkInfo  = this.DisableWalkInfo,
                ThrowOnConflicts = false
            };

            foreach (var operation in resolver.ResolveOperations(package))
            {
                // If the operation is Uninstall, we don't want to uninstall the package if it is in the "retainment" queue.
                if (operation.Action == PackageAction.Install || !_packagesToKeep.Contains(operation.Package))
                {
                    _operations.AddOperation(operation);
                }
            }
        }
Exemplo n.º 2
0
        private void Uninstall(IPackage package, IDependentsResolver dependentsResolver, IPackageRepository repository)
        {
            // If this package isn't part of the current graph (i.e. hasn't been visited yet) and
            // is marked for removal, then do nothing. This is so we don't get unnecessary duplicates.
            if (!Marker.Contains(package) && _operations.Contains(package, PackageAction.Uninstall))
            {
                return;
            }

            // Uninstall the conflicting package. We set throw on conflicts to false since we've
            // already decided that there were no conflicts based on the above code.
            var resolver = new UninstallWalker(repository,
                                               dependentsResolver,
                                               TargetFramework,
                                               NullLogger.Instance,
                                               removeDependencies: !IgnoreDependencies,
                                               forceRemove: false)
            {
                ThrowOnConflicts = false
            };

            foreach (var operation in resolver.ResolveOperations(package))
            {
                _operations.AddOperation(operation);
            }
        }
Exemplo n.º 3
0
 private void Uninstall(IPackage package, IDependentsResolver dependentsResolver, IPackageRepository repository)
 {
     this._packagesToKeep.Remove(package);
     if (base.Marker.Contains(package) || !this._operations.Contains(package, PackageAction.Uninstall))
     {
         UninstallWalker walker1 = new UninstallWalker(repository, dependentsResolver, base.TargetFramework, NullLogger.Instance, !this.IgnoreDependencies, false);
         walker1.DisableWalkInfo  = this.DisableWalkInfo;
         walker1.ThrowOnConflicts = false;
         foreach (PackageOperation operation in walker1.ResolveOperations(package))
         {
             if ((operation.Action == PackageAction.Install) || !this._packagesToKeep.Contains(operation.Package))
             {
                 this._operations.AddOperation(operation);
             }
         }
     }
 }
        public void UninstallPackage(IPackageDetails package)
        {
            Argument.IsNotNull(() => package);
            Argument.IsOfType(() => package, typeof (PackageDetails));

            var dependentsResolver = new DependentsWalker(_localRepository, null);

            var walker = new UninstallWalker(_localRepository, dependentsResolver, null,
                _logger, true, false);

            try
            {
                var nuGetPackage = ((PackageDetails) package).Package;
                var operations = walker.ResolveOperations(nuGetPackage);
                _packageManager.UninstallPackage(nuGetPackage, false, true);
            }
            catch (Exception exception)
            {
                _logger.Log(MessageLevel.Error, exception.Message);
                _packageOperationContextService.CurrentContext.CatchedExceptions.Add(exception);
            }
        }
Exemplo n.º 5
0
        private void Uninstall(IPackage package, IDependentsResolver dependentsResolver, IPackageRepository repository)
        {
            // If this package isn't part of the current graph (i.e. hasn't been visited yet) and
            // is marked for removal, then do nothing. This is so we don't get unnecessary duplicates.
            if (!Marker.Contains(package) && _operations.Contains(package, PackageAction.Uninstall))
            {
                return;
            }

            // Uninstall the conflicting package. We set throw on conflicts to false since we've
            // already decided that there were no conflicts based on the above code.
            var resolver = new UninstallWalker(repository,
                                               dependentsResolver,
                                               TargetFramework,
                                               NullLogger.Instance,
                                               removeDependencies: !IgnoreDependencies,
                                               forceRemove: false) { ThrowOnConflicts = false };

            foreach (var operation in resolver.ResolveOperations(package))
            {
                _operations.AddOperation(operation);
            }
        }
Exemplo n.º 6
0
        private void Uninstall(IPackage package, IDependentsResolver dependentsResolver, IPackageRepository repository)
        {
            // If we explicitly want to uninstall this package, then remove it from the retainment queue.
            _packagesToKeep.Remove(package);

            // If this package isn't part of the current graph (i.e. hasn't been visited yet) and
            // is marked for removal, then do nothing. This is so we don't get unnecessary duplicates.
            if (!Marker.Contains(package) && _operations.Contains(package, PackageAction.Uninstall))
            {
                return;
            }

            // Uninstall the conflicting package. We set throw on conflicts to false since we've
            // already decided that there were no conflicts based on the above code.
            var resolver = new UninstallWalker(
                repository,
                dependentsResolver,
                TargetFramework,
                NullLogger.Instance,
                removeDependencies: !IgnoreDependencies,
                forceRemove: false) 
                {
                    DisableWalkInfo = this.DisableWalkInfo,
                    ThrowOnConflicts = false 
                };

            foreach (var operation in resolver.ResolveOperations(package))
            {
                // If the operation is Uninstall, we don't want to uninstall the package if it is in the "retainment" queue.
                if (operation.Action == PackageAction.Install || !_packagesToKeep.Contains(operation.Package))
                {
                    _operations.AddOperation(operation);
                }
            }
        }
Exemplo n.º 7
0
        protected override void OnBeforePackageWalk(IPackage package)
        {
            ConflictResult conflictResult = GetConflict(package.Id);

            if (conflictResult == null) {
                return;
            }

            // If the conflicting package is the same as the package being installed
            // then no-op
            if (PackageEqualityComparer.IdAndVersion.Equals(package, conflictResult.Package)) {
                return;
            }

            // First we get a list of dependents for the installed package.
            // Then we find the dependency in the foreach dependent that this installed package used to satisfy.
            // We then check if the resolved package also meets that dependency and if it doesn't it's added to the list
            // i.e A1 -> C >= 1
            //     B1 -> C >= 1
            //     C2 -> []
            // Given the above graph, if we upgrade from C1 to C2, we need to see if A and B can work with the new C
            var dependents = from dependentPackage in GetDependents(conflictResult)
                             where !IsDependencySatisfied(dependentPackage, package)
                             select dependentPackage;

            if (dependents.Any()) {
                throw CreatePackageConflictException(package, conflictResult.Package, dependents);
            }
            else if (package.Version < conflictResult.Package.Version) {
                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture,
                    NuGetResources.NewerVersionAlreadyReferenced, package.Id));
            }
            else if (package.Version > conflictResult.Package.Version) {
                // If this package isn't part of the current graph (i.e. hasn't been visited yet) and
                // is marked for removal, then do nothing. This is so we don't get unnecessary duplicates.
                if (!Marker.Contains(conflictResult.Package) &&
                    _operations.Contains(conflictResult.Package, PackageAction.Uninstall)) {
                    return;
                }

                // Uninstall the conflicting package. We set throw on conflicts to false since we've
                // already decided that there were no conflicts based on the above code.
                var resolver = new UninstallWalker(conflictResult.Repository,
                                                   conflictResult.DependentsResolver,
                                                   NullLogger.Instance,
                                                   removeDependencies: !IgnoreDependencies,
                                                   forceRemove: false) { ThrowOnConflicts = false };

                foreach (var operation in resolver.ResolveOperations(conflictResult.Package)) {
                    _operations.AddOperation(operation);
                }
            }
        }
Exemplo n.º 8
0
        protected override void OnBeforePackageWalk(IPackage package)
        {
            ConflictResult conflictResult = GetConflict(package.Id);

            if (conflictResult == null)
            {
                return;
            }

            // If the conflicting package is the same as the package being installed
            // then no-op
            if (PackageEqualityComparer.IdAndVersion.Equals(package, conflictResult.Package))
            {
                return;
            }

            // First we get a list of dependents for the installed package.
            // Then we find the dependency in the foreach dependent that this installed package used to satisfy.
            // We then check if the resolved package also meets that dependency and if it doesn't it's added to the list
            // i.e A1 -> C >= 1
            //     B1 -> C >= 1
            //     C2 -> []
            // Given the above graph, if we upgrade from C1 to C2, we need to see if A and B can work with the new C
            var dependents = from dependentPackage in GetDependents(conflictResult)
                             where !IsDependencySatisfied(dependentPackage, package)
                             select dependentPackage;

            if (dependents.Any())
            {
                throw CreatePackageConflictException(package, conflictResult.Package, dependents);
            }
            else if (package.Version < conflictResult.Package.Version)
            {
                throw new InvalidOperationException(
                          String.Format(CultureInfo.CurrentCulture,
                                        NuGetResources.NewerVersionAlreadyReferenced, package.Id));
            }
            else if (package.Version > conflictResult.Package.Version)
            {
                // If this package isn't part of the current graph (i.e. hasn't been visited yet) and
                // is marked for removal, then do nothing. This is so we don't get unnecessary duplicates.
                if (!Marker.Contains(conflictResult.Package) &&
                    _operations.Contains(conflictResult.Package, PackageAction.Uninstall))
                {
                    return;
                }

                // Uninstall the conflicting package. We set throw on conflicts to false since we've
                // already decided that there were no conflicts based on the above code.
                var resolver = new UninstallWalker(conflictResult.Repository,
                                                   conflictResult.DependentsResolver,
                                                   NullLogger.Instance,
                                                   removeDependencies: !IgnoreDependencies,
                                                   forceRemove: false)
                {
                    ThrowOnConflicts = false
                };

                foreach (var operation in resolver.ResolveOperations(conflictResult.Package))
                {
                    _operations.AddOperation(operation);
                }
            }
        }