private void PrintConflicts(DependencyResolver dependencyResolver, IResolutionResult resolutionResult) { ICollection <DependencyNode> allNodes = new List <DependencyNode>(); foreach (UnresolvedPackage conflict in resolutionResult.ResolutionTable.GetConflictedPackages()) { _writer.Error(dependencyResolver.DescribeConflict(resolutionResult.DependencyNode, conflict, allNodes)); } _writer.Empty(); _writer.Error(dependencyResolver.PrintDependencyNodes(allNodes.Distinct(DependencyNodeComparer.PackageId).OrderBy(n => n.PackageId))); }
private bool Install(IResolutionResult resolutionResult, PackageManifest manifest, string folder, out NuGetVersion oldVersion) { var installed = false; oldVersion = null; var cacheRepository = new CacheRepository(_repositoryFactory.TryGetEnabledRepos(RepositoryScope.Cache)); cacheRepository.PackageDownloadToCacheRepositoryStarted += CacheRepositoryPackageDownloadToCacheRepositoryStarted; cacheRepository.PackageDownloadToCacheRepositoryFinished += CacheRepositoryOnPackageDownloadToCacheRepositoryFinished; cacheRepository.DownloadLocally(resolutionResult.ResolutionTable.GetSatisfyingInfos()); cacheRepository.PackageDownloadToCacheRepositoryStarted -= CacheRepositoryPackageDownloadToCacheRepositoryStarted; cacheRepository.PackageDownloadToCacheRepositoryFinished -= CacheRepositoryOnPackageDownloadToCacheRepositoryFinished; using (var installer = _packageInstallerFactory.GetInstaller(folder, resolutionResult.ResolutionTable, manifest)) { installer.BeginInstallPackage += BeginInstallPackage; installer.FinishInstallPackage += FinishInstallPackage; if (Force) { _writer.Text($"Reinstalling {resolutionResult.ResolutionTable.GetPackages().Count()} packages... "); installer.Reinstall(BuildConfiguration.Release); installed = true; oldVersion = new NuGetVersion(0, 0, 0); } else { var diff = installer.GetDiffWithCurrent(resolutionResult.ResolutionTable.GetSatisfyingInfos()).ToArray(); int changed = PrintSuccess(diff); if (changed > 0) { installer.Upgrade(BuildConfiguration.Release, diff); installed = true; oldVersion = diff[0].OldPackageKey.Version; } else { _writer.Success("No changes detected"); } } installer.BeginInstallPackage -= BeginInstallPackage; installer.FinishInstallPackage -= FinishInstallPackage; } return(installed); }
private void Install(IResolutionResult resolutionResult, PackageManifestRoot manifest, RepositoryScope scope) { if (scope != RepositoryScope.Cache) { var cacheRepo = new CacheRepository(_repositoryFactory.TryGetEnabledRepos(RepositoryScope.Cache)); cacheRepo.PackageDownloadToCacheRepositoryStarted += CacheRepositoryPackageDownloadToCacheRepositoryStarted; cacheRepo.PackageDownloadToCacheRepositoryFinished += CacheRepositoryOnPackageDownloadToCacheRepositoryFinished; cacheRepo.DownloadLocally(resolutionResult.ResolutionTable.GetSatisfyingInfos()); cacheRepo.PackageDownloadToCacheRepositoryStarted -= CacheRepositoryPackageDownloadToCacheRepositoryStarted; cacheRepo.PackageDownloadToCacheRepositoryFinished -= CacheRepositoryOnPackageDownloadToCacheRepositoryFinished; } using (var installer = _packageInstallerFactory.GetInstaller(_manifestResolver.CurrentDirectory, resolutionResult.ResolutionTable, manifest)) { installer.BeginInstallPackage += BeginInstallPackage; installer.FinishInstallPackage += FinishInstallPackage; if (Force) { _writer.Text($"Reinstalling {resolutionResult.ResolutionTable.GetPackages().Count()} packages... "); installer.Reinstall(Configuration); } else { var diff = installer.GetDiffWithCurrent(resolutionResult.ResolutionTable.GetSatisfyingInfos()).ToArray(); int changed = PrintSuccess(diff); if (changed > 0) { installer.Upgrade(Configuration, diff); } else { _writer.Success("No changes detected"); } } installer.BeginInstallPackage -= BeginInstallPackage; installer.FinishInstallPackage -= FinishInstallPackage; } }