public void InstallPackages(IEnumerable <IPackageReference> packageIds, bool allowPreRelease = false) { Guard.AgainstNullArgument("packageIds", packageIds); packageIds = packageIds.Where(packageId => !_installer.IsInstalled(packageId, allowPreRelease)).ToList(); if (!packageIds.Any()) { _logger.Info("Nothing to install."); return; } var exceptions = new List <Exception>(); foreach (var packageId in packageIds) { try { _installer.InstallPackage(packageId, allowPreRelease); } catch (Exception ex) { _logger.Error(ex.Message, ex); exceptions.Add(ex); } } if (exceptions.Any()) { throw new AggregateException(exceptions); } }
public void InstallPackages(IEnumerable <IPackageReference> packageIds, bool allowPreRelease = false, Action <string> packageInstalled = null) { if (packageIds == null) { throw new ArgumentNullException("packageIds"); } packageIds = packageIds.ToList(); if (!packageIds.Any()) { if (packageInstalled != null) { packageInstalled("Nothing to install."); } return; } var successful = packageIds.Select(packageId => _installer.InstallPackage(packageId, allowPreRelease, packageInstalled)) .Aggregate(true, (current, result) => current && result); if (packageInstalled != null && packageIds.Count() > 1) { packageInstalled(successful ? "Installation successful." : "Installation unsuccessful."); } }
public void InstallPackages(IEnumerable <IPackageReference> packageIds, bool allowPreRelease = false) { if (packageIds == null) { throw new ArgumentNullException("packageIds"); } packageIds = packageIds.ToList(); if (!packageIds.Any()) { _logger.Info("Nothing to install."); return; } bool successful = true; foreach (var packageId in packageIds) { if (_installer.IsInstalled(packageId, allowPreRelease)) { continue; } if (!_installer.InstallPackage(packageId, allowPreRelease)) { successful = false; } } if (packageIds.Count() > 1) { _logger.Info(successful ? "Installation successful." : "Installation unsuccessful."); } }
public void InstallPackages(IEnumerable <IPackageReference> packageIds, bool allowPreRelease = false) { if (packageIds == null) { throw new ArgumentNullException(nameof(packageIds)); } packageIds = packageIds.Where(packageId => !_installer.IsInstalled(packageId, allowPreRelease)).ToList(); if (!packageIds.Any()) { _logger.Info("Nothing to install."); return; } var exceptions = new List <Exception>(); foreach (var packageId in packageIds) { try { _installer.InstallPackage(packageId, allowPreRelease); } catch (Exception ex) { _logger.ErrorException("Error installing package.", ex); exceptions.Add(ex); } } if (exceptions.Any()) { throw new AggregateException(exceptions); } }