Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for single project.assets.json file which can be use in p… #509

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions CycloneDX/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ async Task<int> OnExecuteAsync() {
packages = await packagesFileService.GetNugetPackagesAsync(fullSolutionOrProjectFilePath).ConfigureAwait(false);
topLevelComponent.Name = fileSystem.Path.GetDirectoryName(fullSolutionOrProjectFilePath);
}
else if (Program.fileSystem.Path.GetFileName(SolutionOrProjectFile).ToLowerInvariant().Equals("project.assets.json", StringComparison.OrdinalIgnoreCase))
{
packages = projectAssetsFileService.GetNugetPackages(fullSolutionOrProjectFilePath, false);
topLevelComponent.Name = fileSystem.Path.GetDirectoryName(fullSolutionOrProjectFilePath);
}
else if (fileSystem.Directory.Exists(fullSolutionOrProjectFilePath))
{
packages = await packagesFileService.RecursivelyGetNugetPackagesAsync(fullSolutionOrProjectFilePath).ConfigureAwait(false);
Expand Down Expand Up @@ -281,13 +286,14 @@ async Task<int> OnExecuteAsync() {
};
if (package.Dependencies != null)
{
foreach (var dep in package.Dependencies)
foreach (var (key, value) in package.Dependencies)
{
transitiveDepencies.Add(bomRefLookup[(dep.Key.ToLower(CultureInfo.InvariantCulture), dep.Value.ToLower(CultureInfo.InvariantCulture))]);
packageDepencies.Dependencies.Add(new Dependency
{
Ref = bomRefLookup[(dep.Key.ToLower(CultureInfo.InvariantCulture), dep.Value.ToLower(CultureInfo.InvariantCulture))]
});
var component = await nugetService
.GetComponentAsync(new NugetPackage { Name = key, Version = value })
.ConfigureAwait(false);

transitiveDepencies.Add(component.BomRef);
packageDepencies.Dependencies.Add(new Dependency { Ref = component.BomRef });
}
}
dependencies.Add(packageDepencies);
Expand Down