Skip to content

Commit

Permalink
draftForFixing739
Browse files Browse the repository at this point in the history
Signed-off-by: CodeTiger <[email protected]>
  • Loading branch information
mtsfoni committed Nov 8, 2023
1 parent 8a6ad3d commit 6fa55b5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions CycloneDX/Services/ProjectAssetsFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ public HashSet<NugetPackage> GetNugetPackages(string projectFilePath, string pro
runtimePackages.Add(package);
}

var allDependencies = runtimePackages.SelectMany(y => y.Dependencies.Keys).Distinct();
var allPackages = runtimePackages.Select(p => p.Name);
var packagesNotInAllPackages = allDependencies.Except(allPackages);

// Check if there is an "unresolved" dependency on NetStandard
if (packagesNotInAllPackages.Any(p => p == "NETStandard.Library"))
{
// If a project library has targets .net standard it actually doesn't resolve this dependency
// instead it is expected to find the Standard-Libraries on the target system
// => the libraries not being part of the resulting application and thus should not be included in
// the sbom anyways
foreach (var item in runtimePackages)
{
item.Dependencies.Remove("NETStandard.Library");
}
}

ResolveDependencyVersionRanges(runtimePackages);

packages.UnionWith(runtimePackages);
Expand Down

0 comments on commit 6fa55b5

Please sign in to comment.