SBOMs for .NET and NuGet
sbombox generate does not detect .NET projects yet. Generate the SBOM with the CycloneDX .NET tool or Microsoft's sbom-tool, then upload it with sbombox push, which accepts any CycloneDX or SPDX file.
At a glance
| Package manager | Built-in SBOM command | What sbombox generate runs | Lockfile to commit |
|---|---|---|---|
NuGet (dotnet) | No | Not detected; use a tool below, then sbombox push | packages.lock.json |
Turn on the NuGet lockfile with <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> in your project, commit packages.lock.json, and restore with dotnet restore --locked-mode in CI.
Generate with the CycloneDX .NET tool
This is the shortest path to a CycloneDX SBOM. -t excludes test projects.
curl -fsSL https://sbombox.com/install.sh | sh
dotnet tool install --global CycloneDX
dotnet-CycloneDX MySolution.sln -o . -fn sbom.json -F Json -t -sv 1.4.0-ois the output directory and-fnthe file name.-svsets the version of the root component, not the spec version. It defaults to0.0.0.- Dev and test-only dependencies are included with
scope: "excluded"by default.
# See what lowers the score
sbombox score sbom.json --format detailed
# Check a ruleset, e.g. EU Cyber Resilience Act readiness
sbombox compliance sbom.json -p cra-readiness
# Upload it to the active project, labelled with the release
sbombox push sbom.json --version v1.4.0Generate with Microsoft sbom-tool
sbom-tool writes SPDX from your build output. Point -b at the published output and -bc at the source.
dotnet tool install --global Microsoft.Sbom.DotNetTool
dotnet publish -c Release -o ./publish
sbom-tool generate -b ./publish -bc . -pn MyApp -pv 1.4.0 -ps "Example Corp" -nsb https://example.com/sbom
sbombox push ./publish/_manifest/spdx_2.2/manifest.spdx.json --version v1.4.0sbom-tool defaults to SPDX 2.2. Add -mi SPDX:3.0 for SPDX 3.0.
Using a universal tool
cdxgen and syft also read .NET projects. Because SBOMBox does not detect .NET, run them directly and upload the result. cdxgen notes that .NET SBOMs can include components without a version, so check the score.
syft dir:. -o cyclonedx-json=sbom.json
sbombox push sbom.json --version v1.4.0Monorepos and solutions
- Generate from the
.slnfor one SBOM covering every project, or from each.csprojfor one per service. - Upload each deployable service to its own SBOMBox project with
sbombox push FILE --project ID. See Unify SBOMs.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Could not detect project ecosystem in <dir>: no supported manifest or lockfile. | sbombox generate does not detect .NET | Use the CycloneDX .NET tool or sbom-tool, then sbombox push |
| xUnit or NUnit in the SBOM | Test projects included | Add -t to dotnet-CycloneDX |
Root component version 0.0.0 | No -sv passed | Pass -sv with your release version |
| Components with no version | No lockfile, or a universal tool guessed | Commit packages.lock.json; prefer the CycloneDX .NET tool |
In CI, run the same commands. See GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, Bitbucket Pipelines or CircleCI, or use the GitHub Action.