IEnumerable <PackageOperationResult> CleanProjectPackagesCore(IEnumerable <IPackageDescriptor> projectDescriptors, ISupportCleaning projectRepository, Func <string, bool> packageName)
        {
            var resolvedPackages = projectDescriptors.Select(projectDescriptor => new{ projectDescriptor, result = _resolver.TryResolveDependencies(projectDescriptor, new[] { projectRepository }) });

            var failing = resolvedPackages.FirstOrDefault(x => x.result.SuccessfulPackages.Any() == false);

            if (failing != null)
            {
                yield return(new PackageCleanCannotDo(failing.projectDescriptor));

                yield break;
            }
            var projectPackagesInUse = from successfulPackageStack in resolvedPackages.SelectMany(x => x.result.SuccessfulPackages)
                                       from package in successfulPackageStack.Packages
                                       where packageName(package.Identifier.Name)
                                       select package;

            var otherPackages = from packagesByName in projectRepository.PackagesByName
                                where !packageName(packagesByName.Key)
                                from package in packagesByName
                                select package;
            var packagesInUse = projectPackagesInUse.Concat(otherPackages).ToList();


            foreach (var cleanedPackage in projectRepository.Clean(packagesInUse))
            {
                yield return(cleanedPackage);
            }
        }
 IEnumerable<ICommandOutput> CleanRepository(ISupportCleaning repository, IEnumerable<IPackageInfo> packagesToKeep)
 {
     foreach (var package in repository.Clean(packagesToKeep))
     {
         if (package.Success)
             yield return new GenericMessage("Package '{0}' removed.", package.Package.FullName);
         else
             yield return new GenericMessage("Package '{0}' could not be removed, possibly because a file is still in use. If you use Visual Studio, try closing it and retrying.", package.Package.FullName);
     }
     repository.RefreshAnchors(PackageManager.TryResolveDependencies(Environment.Descriptor, new[] { Environment.ProjectRepository }));
 }
        IEnumerable <PackageOperationResult> CleanSystemPackagesCore(ISupportCleaning systemRepository, Func <string, bool> packageNameSelector)
        {
            var selectedPackages = from packageByName in systemRepository.PackagesByName
                                   where packageNameSelector(packageByName.Key)
                                   select packageByName.OrderByDescending(x => x.Version).First();

            var untouchedVersions = systemRepository.PackagesByName.Where(x => !packageNameSelector(x.Key)).SelectMany(x => x);

            foreach (var clean in systemRepository.Clean(selectedPackages.Concat(untouchedVersions)))
            {
                yield return(clean);
            }
        }
Beispiel #4
0
 IEnumerable<ICommandOutput> RemoveFromRepository(ISupportCleaning repository)
 {
     if (Last)
         Version = repository.PackagesByName[Name].Select(x=>x.Version)
                                                  .OrderByDescending(x => x)
                                                  .FirstOrDefault();
     return repository.Clean(repository.PackagesByName
                                           .SelectMany(x => x)
                                           .Where(PackageShouldBeKept))
                                           .Select(PackageRemovedMessage);
 }
        IEnumerable<PackageOperationResult> CleanSystemPackagesCore(ISupportCleaning systemRepository, Func<string, bool> packageNameSelector)
        {
            var lastVersions = from packageByName in systemRepository.PackagesByName
                               where packageNameSelector(packageByName.Key)
                               select packageByName.OrderByDescending(x => x.Version).First();

            var untouchedVersions = systemRepository.PackagesByName.Where(x => !packageNameSelector(x.Key)).SelectMany(x => x);

            foreach (var clean in systemRepository.Clean(lastVersions.Concat(untouchedVersions)))
                yield return clean;
        }
        IEnumerable<PackageOperationResult> CleanProjectPackagesCore(PackageDescriptor projectDescriptor, ISupportCleaning projectRepository, Func<string, bool> packageName)
        {
            var resolvedPackages = _resolver.TryResolveDependencies(projectDescriptor, new[] { projectRepository });
            if(resolvedPackages.SuccessfulPackages.Any() == false)
            {
                yield return new PackageCleanCannotDo(projectDescriptor);
                yield break;
            }
            var projectPackagesInUse = from successfulPackageStack in resolvedPackages.SuccessfulPackages
                                       from package in successfulPackageStack.Packages
                                       where packageName(package.Identifier.Name)
                                       select package;

            var otherPackages = from packagesByName in projectRepository.PackagesByName
                                where !packageName(packagesByName.Key)
                                from package in packagesByName
                                select package;
            var packagesInUse = projectPackagesInUse.Concat(otherPackages).ToList();

            foreach (var cleanedPackage in projectRepository.Clean(packagesInUse))
                yield return cleanedPackage;
            foreach (var anchored in AnchorPackages(resolvedPackages, new[] { projectRepository }))
                yield return anchored;
        }
 IEnumerable<ICommandOutput> CleanRepository(ISupportCleaning repository, IEnumerable<IPackageInfo> packagesToKeep)
 {
     foreach (var removedRepo in repository.Clean(packagesToKeep))
         yield return new GenericMessage("Removed package '{0}'.", removedRepo.FullName);
     repository.RefreshAnchors(PackageManager.TryResolveDependencies(Environment.Descriptor, new[] { Environment.ProjectRepository }));
 }