Skip to content

Commit

Permalink
Fix: #739 remove .net-standard as dependency, as it is not in the sco…
Browse files Browse the repository at this point in the history
…pe of delivery

Signed-off-by: CodeTiger <[email protected]>
  • Loading branch information
mtsfoni authored Dec 14, 2023
1 parent 1d858e9 commit 291333d
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 291333d

Please sign in to comment.