Skip to content

Commit

Permalink
Program may fail with multiple repositories configured.
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-englert committed Jun 20, 2023
1 parent d0e06f2 commit 6a6b674
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/LicenseGenerator/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task<int> Build()

private async Task<ICollection<PackageArchiveReader>> LoadPackages()
{
var packageSourceProvider = new PackageSourceProvider(new Settings(_solutionDirectory));
var packageSourceProvider = new PackageSourceProvider(Settings.LoadDefaultSettings(_solutionDirectory));
var sourceRepositoryProvider = new SourceRepositoryProvider(packageSourceProvider, Repository.Provider.GetCoreV3());
var repositories = sourceRepositoryProvider.GetRepositories().ToArray();

Expand Down Expand Up @@ -169,6 +169,8 @@ private async Task LoadPackage(ProjectInfo projectInfo, PackageIdentity packageI
NullLogger.Instance, CancellationToken.None);

packageStream.Position = 0;
if (packageStream.Length == 0)
continue; // Try next repo

var package = new PackageArchiveReader(packageStream);

Expand All @@ -178,7 +180,7 @@ private async Task LoadPackage(ProjectInfo projectInfo, PackageIdentity packageI
var spec = new NuspecReader(nuspec);
var projectUrl = spec.GetProjectUrl();
if (!string.IsNullOrEmpty(projectUrl))
continue;
return;

// we don't have license information for this package, so scan dependencies
var dependencies = package
Expand All @@ -197,6 +199,8 @@ private async Task LoadPackage(ProjectInfo projectInfo, PackageIdentity packageI
// Ignore dependencies that can't be loaded.
}
}

return;
}
}

Expand Down

0 comments on commit 6a6b674

Please sign in to comment.