diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 52ebaf4fd0..f1b1493855 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -968,36 +968,43 @@ private IPackage find_package(string packageName, SemanticVersion version, Choco foreach (var packageRepository in aggregateRepository.Repositories.or_empty_list_if_null()) { - this.Log().Debug("Using '" + packageRepository.Source + "'."); - this.Log().Debug("- Supports prereleases? '" + packageRepository.SupportsPrereleasePackages + "'."); - this.Log().Debug("- Is ServiceBased? '" + (packageRepository is IServiceBasedRepository) + "'."); + try + { + this.Log().Debug("Using '" + packageRepository.Source + "'."); + this.Log().Debug("- Supports prereleases? '" + packageRepository.SupportsPrereleasePackages + "'."); + this.Log().Debug("- Is ServiceBased? '" + (packageRepository is IServiceBasedRepository) + "'."); - // search based on lower case id - similar to PackageRepositoryExtensions.FindPackagesByIdCore() - IQueryable combinedResults = packageRepository.GetPackages().Where(x => x.Id.ToLower() == packageName); + // search based on lower case id - similar to PackageRepositoryExtensions.FindPackagesByIdCore() + IQueryable combinedResults = packageRepository.GetPackages().Where(x => x.Id.ToLower() == packageName); - if (config.Prerelease && packageRepository.SupportsPrereleasePackages) - { - combinedResults = combinedResults.Where(p => p.IsAbsoluteLatestVersion); - } - else - { - combinedResults = combinedResults.Where(p => p.IsLatestVersion); - } + if (config.Prerelease && packageRepository.SupportsPrereleasePackages) + { + combinedResults = combinedResults.Where(p => p.IsAbsoluteLatestVersion); + } + else + { + combinedResults = combinedResults.Where(p => p.IsLatestVersion); + } - if (!(packageRepository is IServiceBasedRepository)) - { - combinedResults = combinedResults - .Where(PackageExtensions.IsListed) - .Where(p => config.Prerelease || p.IsReleaseVersion()) - .distinct_last(PackageEqualityComparer.Id, PackageComparer.Version) - .AsQueryable(); - } + if (!(packageRepository is IServiceBasedRepository)) + { + combinedResults = combinedResults + .Where(PackageExtensions.IsListed) + .Where(p => config.Prerelease || p.IsReleaseVersion()) + .distinct_last(PackageEqualityComparer.Id, PackageComparer.Version) + .AsQueryable(); + } - var packageRepositoryResults = combinedResults.ToList(); - if (packageRepositoryResults.Count() != 0) + var packageRepositoryResults = combinedResults.ToList(); + if (packageRepositoryResults.Count() != 0) + { + this.Log().Debug("Package '{0}' found on source '{1}'".format_with(packageName, packageRepository.Source)); + packageResults.AddRange(packageRepositoryResults); + } + } + catch (Exception e) { - this.Log().Debug("Package '{0}' found on source '{1}'".format_with(packageName, packageRepository.Source)); - packageResults.AddRange(packageRepositoryResults); + this.Log().Warn("Error retrieving packages from source '{0}':{1} {2}".format_with(packageRepository.Source, Environment.NewLine, e.Message)); } }