Skip to content

Commit

Permalink
fix: catch PackagesConfigReaderException in `NuGetPackagesConfigDet…
Browse files Browse the repository at this point in the history
…ector` (#362)
  • Loading branch information
JamieMagee authored Nov 9, 2022
1 parent 5bc355e commit 678bdff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@ public class NuGetPackagesConfigDetector : FileComponentDetector
protected override Task OnFileFound(ProcessRequest processRequest, IDictionary<string, string> detectorArgs)
{
var packagesConfig = new PackagesConfigReader(processRequest.ComponentStream.Stream);
foreach (var package in packagesConfig.GetPackages(allowDuplicatePackageIds: true))
try
{
processRequest.SingleFileComponentRecorder.RegisterUsage(
new DetectedComponent(
new NuGetComponent(
package.PackageIdentity.Id,
package.PackageIdentity.Version.ToNormalizedString())),
true,
null,
package.IsDevelopmentDependency);
foreach (var package in packagesConfig.GetPackages(allowDuplicatePackageIds: true))
{
processRequest.SingleFileComponentRecorder.RegisterUsage(
new DetectedComponent(
new NuGetComponent(
package.PackageIdentity.Id,
package.PackageIdentity.Version.ToNormalizedString())),
true,
null,
package.IsDevelopmentDependency);
}
}
catch (PackagesConfigReaderException e)
{
this.Logger.LogFailedReadingFile(processRequest.ComponentStream.Location, e);
}

return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- https://github.com/dotnet/Kerberos.NET/blob/559bec87d6eb1fb8698418c3aacafbbc7c32bdec/Samples/KerberosWebSample/packages.config -->
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- https://github.com/dotnet/Kerberos.NET/blob/559bec87d6eb1fb8698418c3aacafbbc7c32bdec/Samples/KerberosWebSample/packages.config -->
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
Expand Down

0 comments on commit 678bdff

Please sign in to comment.