Inheritance: PackageWalker
Exemplo n.º 1
0
        private IEnumerable <PackageAction> ResolveActionsToUpdateAllPackages(IEnumerable <IProjectManager> projectManagers)
        {
            IEnumerable <IPackage> enumerable = new PackageSorter(null).GetPackagesByDependencyOrder(projectManagers.First <IProjectManager>().PackageManager.LocalRepository).Reverse <IPackage>();

            foreach (IProjectManager manager in projectManagers)
            {
                foreach (IPackage package in enumerable)
                {
                    IProjectManager[] managerArray1 = new IProjectManager[] { manager };
                    this.AddUpdateOperations(package.Id, null, managerArray1);
                }
            }
            return(this.Resolver.ResolveActions());
        }
Exemplo n.º 2
0
        IEnumerable<Resolver.PackageAction> ResolveActionsToUpdateAllPackages(IEnumerable<IProjectManager> projectManagers)
        {
            // BUGBUG: TargetFramework should be passed for more efficient package walking
            var packageSorter = new PackageSorter(targetFramework: null);
            // Get the packages in reverse dependency order then run update on each one i.e. if A -> B run Update(A) then Update(B)
            var packages = packageSorter.GetPackagesByDependencyOrder(
                projectManagers.First().PackageManager.LocalRepository).Reverse();

            foreach (var projectManager in projectManagers)
            {
                foreach (var package in packages)
                {
                    AddUpdateOperations(
                        package.Id,
                        null,
                        new[] { projectManager });
                }
            }

            var actions = Resolver.ResolveActions();
            return actions;
        }
Exemplo n.º 3
0
        IEnumerable <Resolver.PackageAction> ResolveActionsToUpdateAllPackages(IEnumerable <IProjectManager> projectManagers)
        {
            // BUGBUG: TargetFramework should be passed for more efficient package walking
            var packageSorter = new PackageSorter(targetFramework: null);
            // Get the packages in reverse dependency order then run update on each one i.e. if A -> B run Update(A) then Update(B)
            var packages = packageSorter.GetPackagesByDependencyOrder(
                projectManagers.First().PackageManager.LocalRepository).Reverse();

            foreach (var projectManager in projectManagers)
            {
                foreach (var package in packages)
                {
                    AddUpdateOperations(
                        package.Id,
                        null,
                        new[] { projectManager });
                }
            }

            var actions = Resolver.ResolveActions();

            return(actions);
        }
		public IEnumerable<IPackage> GetPackagesInReverseDependencyOrder()
		{
			var packageSorter = new PackageSorter(null);
			return packageSorter
				.GetPackagesByDependencyOrder(projectManager.LocalRepository)
				.Reverse();
		}
Exemplo n.º 5
0
        public IEnumerable<string> UpdateAllPackages()
        {
            var packageSorter = new PackageSorter(targetFramework: TargetFramework);
            // Get the packages in reverse dependency order then run update on each one i.e. if A -> B run Update(A) then Update(B)
            var packagesToUpdate = GetPackagesWithUpdates(null, false);
            var packages = packageSorter.GetPackagesByDependencyOrder(LocalRepository).Reverse();
            var allErrors = new List<string>();

            foreach (var package in packages)
            {
                var packageToUpdateNow = packagesToUpdate.Where(p => p.Id.Equals(package.Id, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                if (packageToUpdateNow != null)
                {
                    // While updating we might remove packages that were initially in the list. e.g.
                    // A 1.0 -> B 2.0, A 2.0 -> [], since updating to A 2.0 removes B, we end up skipping it.
                    if (LocalRepository.Exists(packageToUpdateNow.Id))
                    {
                        AppDomain appDomain = null;
                        try
                        {
                            appDomain = AppDomain.CreateDomain(Guid.NewGuid().ToString());
                            var errors = UpdatePackage(packageToUpdateNow, appDomain);
                            if (!errors.IsEmpty())
                            {
                                allErrors.Concat(errors);
                            }
                        }
                        finally
                        {
                            if (appDomain != null)
                            {
                                AppDomain.Unload(appDomain);
                            }
                        }
                    }
                }
            }
            return allErrors;
        }
		public IEnumerable<IPackage> GetPackagesByDependencyOrder()
		{
			var packageSorter = new PackageSorter(null);
			return packageSorter.GetPackagesByDependencyOrder(repository);
		}
Exemplo n.º 7
0
        private void ExecuteInitScripts()
        {
            // Fix for Bug 1426 Disallow ExecuteInitScripts from being executed concurrently by multiple threads.
            lock (_initScriptsLock)
            {
                if (!_solutionManager.IsSolutionOpen)
                {
                    return;
                }

                IRepositorySettings repositorySettings = ServiceLocator.GetInstance<IRepositorySettings>();
                Debug.Assert(repositorySettings != null);
                if (repositorySettings == null)
                {
                    return;
                }

                try
                {
                    var localRepository = new LocalPackageRepository(repositorySettings.RepositoryPath);

                    // invoke init.ps1 files in the order of package dependency.
                    // if A -> B, we invoke B's init.ps1 before A's.

                    var sorter = new PackageSorter();
                    var sortedPackages = sorter.GetPackagesByDependencyOrder(localRepository);

                    foreach (var package in sortedPackages)
                    {
                        string installPath = localRepository.PathResolver.GetInstallPath(package);

                        AddPathToEnvironment(Path.Combine(installPath, "tools"));
                        Runspace.ExecuteScript(installPath, "tools\\init.ps1", package);
                    }
                }
                catch (Exception ex)
                {
                    // if execution of Init scripts fails, do not let it crash our console
                    ReportError(ex);

                    ExceptionHelper.WriteToActivityLog(ex);
                }
            }
        }
Exemplo n.º 8
0
        private void ExecuteInitScripts()
        {
            if (!String.IsNullOrEmpty(_solutionManager.SolutionDirectory)) {
                try {
                    var packageManager = (VsPackageManager)_packageManagerFactory.CreatePackageManager();
                    var localRepository = packageManager.LocalRepository;

                    // invoke init.ps1 files in the order of package dependency.
                    // if A -> B, we invoke B's init.ps1 before A's.

                    var sorter = new PackageSorter();
                    var sortedPackages = sorter.GetPackagesByDependencyOrder(localRepository);

                    foreach (var package in sortedPackages) {
                        string installPath = packageManager.PathResolver.GetInstallPath(package);

                        AddPathToEnvironment(Path.Combine(installPath, "tools"));
                        Runspace.ExecuteScript(installPath, "tools\\init.ps1", package);
                    }
                }
                catch (Exception ex) {
                    // if execution of Init scripts fails, do not let it crash our console
                    ReportError(ex);

                    ExceptionHelper.WriteToActivityLog(ex);
                }
            }
        }
        private IEnumerable<IPackage> GetPackages(IPackageRepository repository)
        {
            var packages = repository.GetPackages();
            if (Id.Any())
            {
                var packageIdSet = new HashSet<string>(packages.Select(r => r.Id), StringComparer.OrdinalIgnoreCase);
                var idSet = new HashSet<string>(Id, StringComparer.OrdinalIgnoreCase);
                var invalid = Id.Where(id => !packageIdSet.Contains(id));

                if (invalid.Any())
                {
                    throw new BuildException(String.Format("Unable to find packages {0}", String.Join(", ", invalid)), Location);
                }

                packages = packages.Where(r => idSet.Contains(r.Id));
            }
            var packageSorter = new PackageSorter(targetFramework: null);
            return packageSorter.GetPackagesByDependencyOrder(new ReadOnlyPackageRepository(packages)).Reverse();
        }