Skip to content

Commit

Permalink
skip packages that have bad nuspecs
Browse files Browse the repository at this point in the history
  • Loading branch information
johnataylor committed Sep 3, 2015
1 parent f74df7c commit c8763e4
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/Core/Repositories/ExpandedPackageRepository.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System.Collections.Generic;
using NuGet.Resources;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;

namespace NuGet
{
Expand Down Expand Up @@ -95,7 +98,12 @@ public IEnumerable<IPackage> FindPackagesById(string packageId)
if (SemanticVersion.TryParse(versionDirectoryName, out version) &&
Exists(packageId, version))
{
yield return GetPackageInternal(packageId, version);
var package = GetPackageInternal(packageId, version);
if (package == null)
{
continue;
}
yield return package;
}
}
}
Expand All @@ -117,9 +125,24 @@ private static string GetPackageRoot(string packageId, SemanticVersion version)

private IPackage GetPackageInternal(string packageId, SemanticVersion version)
{
var packagePath = GetPackagePath(packageId, version);
var manifestPath = Path.Combine(GetPackageRoot(packageId, version), packageId + Constants.ManifestExtension);
return new ZipPackage(() => _fileSystem.OpenFile(packagePath), () => _fileSystem.OpenFile(manifestPath));
var manifestPath = string.Empty;
try
{
var packagePath = GetPackagePath(packageId, version);
manifestPath = Path.Combine(GetPackageRoot(packageId, version), packageId + Constants.ManifestExtension);
return new ZipPackage(() => _fileSystem.OpenFile(packagePath), () => _fileSystem.OpenFile(manifestPath));
}
catch (XmlException ex)
{
_fileSystem.Logger.Log(MessageLevel.Warning, ex.Message);
}
catch (IOException ex)
{
_fileSystem.Logger.Log(MessageLevel.Warning, ex.Message);
}

_fileSystem.Logger.Log(MessageLevel.Warning, NuGetResources.Manifest_NotFound, manifestPath);
return null;
}

private static string GetPackagePath(string packageId, SemanticVersion version)
Expand Down

0 comments on commit c8763e4

Please sign in to comment.