static IEnumerable<IAssemblyReferenceExportItem> GetAssemblyReferences(DependencyResolutionResult resolveResult, ExecutionEnvironment exec, bool includeContentOnly)
 {
     var packages = resolveResult.Dependencies
             .Where(x=> includeContentOnly || !IsInContentBranch(x))
             .Select(x => x.Package);
     return GetAssemblyReferencesFromPackages(packages, exec);
 }
Beispiel #2
0
 ICommandResult DependencyResolutionFailed(DependencyResolutionResult result)
 {
     return new Result("Dependency resolution failed.")
     {
         Success = false
     };
 }
        public static IEnumerable<ICommandOutput> CopyPackagesToRepositories(this IPackageManager manager,
            DependencyResolutionResult dependencies,
            IEnumerable<IPackageRepository> repositoriesToWriteTo)
        {
            if (manager == null) throw new ArgumentNullException("manager");
            if (dependencies == null) throw new ArgumentNullException("dependencies");
            if (repositoriesToWriteTo == null) throw new ArgumentNullException("repositoriesToWriteTo");

            if (!dependencies.IsSuccess)
            {
                yield return DependencyResolutionFailed(dependencies);
                yield break;
            }

            foreach (var dependency in dependencies.Dependencies)
            {
                // fast forward to the source repository

                var repositoriesForDependency = repositoriesToWriteTo
                    .SkipWhile(x => x != dependency.Package.Source)
                    .Skip(1)
                    .ToList();

                if (repositoriesForDependency.Count == 0)
                    repositoriesForDependency = repositoriesToWriteTo.ToList();

                foreach (var repository in repositoriesForDependency.Where(x => x != null && x.CanPublish))
                {
                    yield return new Result("Copying '{0}' to '{1}'", dependency.Package.FullName, repository.Name);
                    manager.UpdateDependency(dependency, repository);
                }
            }
        }
        public static void RefreshAnchors(this IPackageRepository repo, DependencyResolutionResult resolvedPackages)
        {
            var projectRepo = repo as ISupportAnchoring;
            if (projectRepo != null)
            {
                var packagesToAnchor = resolvedPackages.Dependencies
                    .Where(x => x.Dependency.Anchored || (x.Package != null && x.Package.Anchored))
                    .Select(x=>x.Package)
                    .NotNull()
                    .Where(x=>x.Source == projectRepo).ToList();

                projectRepo.VerifyAnchors(packagesToAnchor);
            }
        }
 public DependencyResolutionFailedResult(string message, DependencyResolutionResult result)
 {
     _message = message;
     _result = result;
 }
 public DependencyResolutionFailedResult(DependencyResolutionResult result)
     : this("The following dependencies were not found:", result)
 {
     Result = result;
 }
        IEnumerable<ICommandOutput> UpdateSystemPackages()
        {
            if (!System) yield break;

            yield return new Result("Searching for updated packages...");
            foreach (var packageToSearch in CreateDescriptorForEachSystemPackage())
            {
                var sourceRepos = Environment.RemoteRepositories.Concat(Environment.CurrentDirectoryRepository).ToList();

                var resolveResult = PackageResolver.TryResolveDependencies(packageToSearch, sourceRepos);
                var successful = resolveResult.ResolvedPackages.Where(x => x.Package != null).ToList();
                resolveResult = new DependencyResolutionResult { IsSuccess = successful.Count > 0, ResolvedPackages = successful };
                if (!resolveResult.IsSuccess)
                    continue;
                foreach (var m in PackageResolver.CopyPackagesToRepositories(resolveResult, Environment.SystemRepository))
                    if (m is DependencyResolutionFailedResult)
                        yield return PackageNotFoundInRemote((DependencyResolutionFailedResult)m);

                    else
                        yield return m;
                foreach (var m in VerifyPackageCache(packageToSearch)) yield return m;
            }
        }
        IEnumerable<ICommandOutput> FailedUpdate(DependencyResolutionResult resolvedPackages, IEnumerable<IPackageRepository> sourceRepos)
        {
            foreach(var notFoundPackage in resolvedPackages.ResolvedPackages.Where(x=>x.Package == null))
                yield return new DependenciesNotFoundInRepositories(notFoundPackage.Dependencies, sourceRepos);

            var conflictingDependencies = resolvedPackages.ResolvedPackages
                    .Where(x => x.Package != null)
                    .GroupBy(x => x.Package.Name, StringComparer.OrdinalIgnoreCase)
                    .Where(x => x.Count() > 1);

            if (conflictingDependencies.Count() > 0)
                yield return new DependenciesConflictMessage(conflictingDependencies.ToList());
        }
 IEnumerable<PackageOperationResult> ReturnError(DependencyResolutionResult resolvedPackages)
 {
     return resolvedPackages.DiscardedPackages.Select(PackageConflict)
             .Concat(resolvedPackages.MissingPackages.Select(PackageMissing));
 }
        IEnumerable<PackageOperationResult> CopyPackagesToRepositories(IEnumerable<IPackageRepository> sourceRepositories,
            DependencyResolutionResult resolvedPackages,
            IEnumerable<IPackageRepository> destinationRepositories)
        {
            var publishingRepos = destinationRepositories.NotNull().OfType<ISupportPublishing>().ToList();
            foreach (var foundPackage in resolvedPackages.SuccessfulPackages)
            {
                foreach (var destinationRepository in publishingRepos)
                {
                    var existingUpToDateVersion = GetExistingPackage(destinationRepository, foundPackage, x => x >= foundPackage.Identifier.Version);
                    if (existingUpToDateVersion == null)
                    {
                        var sourcePackage = GetBestSourcePackage(sourceRepositories, foundPackage.Packages);

                        _deployer.DeployDependency(sourcePackage, destinationRepository);
                        var existingVersion = GetExistingPackage(destinationRepository, foundPackage, x => x < foundPackage.Identifier.Version);

                        yield return existingVersion == null
                            ? new PackageAddedResult(sourcePackage, destinationRepository)
                            : new PackageUpdatedResult(existingVersion, sourcePackage, destinationRepository);
                    }
                    else
                    {
                        yield return new PackageUpToDateResult(existingUpToDateVersion, destinationRepository);
                    }
                }
            }
            foreach (var repo in publishingRepos)
                repo.PublishCompleted();
        }
 static IEnumerable<PackageAnchoredResult> AnchorPackages(DependencyResolutionResult resolvedPackages, IEnumerable<IPackageRepository> destinationRepositories)
 {
     return from repo in destinationRepositories.OfType<ISupportAnchoring>()
            from successfulPackage in resolvedPackages.SuccessfulPackages
            where successfulPackage.IsAnchored
            let packageInstances = from packageInstance in successfulPackage.Packages
                                   where packageInstance != null &&
                                         packageInstance.Source == repo
                                   select packageInstance
            from anchorResult in repo.AnchorPackages(packageInstances)
            select anchorResult;
 }
Beispiel #12
0
        //public IEnumerable<SystemPackage> SystemDependencies { get { return Environment.SystemRepository.PackagesByName.Select(x => new SystemPackage(x.Key, x)); } }
        public WrapSlice(string noun, IEnumerable<VerbSlice> commandDescriptors) : base(noun, commandDescriptors)
        {

            if (Environment != null && Environment.ProjectRepository != null)
            {
                ProjectDependencies = PackageResolver.TryResolveDependencies(Environment.Descriptor, new[] { Environment.ProjectRepository });
            }
        }
 static IEnumerable<IAssemblyReferenceExportItem> GetAssemblyReferences(DependencyResolutionResult resolveResult, ExecutionEnvironment exec, bool includeContentOnly)
 {
     var packages = resolveResult.SuccessfulPackages.Where(resolvedPackage => includeContentOnly || !resolvedPackage.IsInContentBranch).SelectMany(x=>x.Packages);
     return GetAssemblyReferencesFromPackages(packages, exec);
 }
 public static IEnumerable<ICommandOutput> CopyPackagesToRepositories(this IPackageManager manager, DependencyResolutionResult dependencies, params IPackageRepository[] repositories)
 {
     return CopyPackagesToRepositories(manager, dependencies, (IEnumerable<IPackageRepository>)repositories);
 }