Skip to content

Duplicate refs in dependsOn since v6.3.0 #1143

Open

Description

@pf56

Summary

When several projects in a solution depend on the same package, but one of that package's dependencies is missing from the restored dependency graph of some of those projects (through PrivateAssets = "all"), the generated BOM lists that dependency twice in the package's dependsOn array. The generated manifest then violates the CycloneDX 1.6 schema.

Trying to upload the file to DependencyTrack results in this error:

{
    "status": 400,
    "title": "The uploaded BOM is invalid",
    "detail": "Schema validation failed",
    "errors": [
        "/dependencies/<number>/dependsOn: must have only unique items in the array"
    ]
}

Repro

It's a bit hard to explain IMO, so here is a minimal sample that reproduces the issue.

Repro.slnx

<Solution>
  <Project Path="Api/Api.csproj" />
  <Project Path="Consumer/Consumer.csproj" />
</Solution>

Api.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Swashbuckle.AspNetCore" Version="10.0.1" />
    <PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="10.0.11" PrivateAssets="all" />
  </ItemGroup>
</Project>

Consumer.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="../Api/Api.csproj" />
  </ItemGroup>
</Project>

nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

Commands to run:

$ dotnet restore Repro.slnx
$ dotnet tool install -g CycloneDX --version 6.3.1
$ dotnet CycloneDX Repro.slnx -o out -F Json

The resulting out/bom.json then contains a duplicate entry in Swashbuckle.AspnetCore's dependsOn.

"dependencies": [
    ...
    {
      "ref": "pkg:nuget/Swashbuckle.AspNetCore@10.0.1",
      "dependsOn": [
        "pkg:nuget/Microsoft.Extensions.ApiDescription.Server@10.0.11",
        "pkg:nuget/Swashbuckle.AspNetCore.Swagger@10.0.1",
        "pkg:nuget/Swashbuckle.AspNetCore.SwaggerGen@10.0.1",
        "pkg:nuget/Swashbuckle.AspNetCore.SwaggerUI@10.0.1",
        "pkg:nuget/Microsoft.Extensions.ApiDescription.Server@10.0.11"   <--- duplicated
      ]
    },
    ...
  ]

This seems to only affect versions >= 6.3.0. v6.2.1 does not duplicate the entry.

Activity

  1. added a commit that references this issue on Oct 15, 2026
    6573ceb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageDon't know what to do with this yet

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions