Languages

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

.NET and SBOMBox
Package managerBuilt-in SBOM commandWhat sbombox generate runsLockfile to commit
NuGet (dotnet)NoNot detected; use a tool below, then sbombox pushpackages.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
# 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.0

Generate 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.0

sbom-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.0

Monorepos and solutions

Troubleshooting

Common .NET issues
SymptomCauseFix
Could not detect project ecosystem in <dir>: no supported manifest or lockfile.sbombox generate does not detect .NETUse the CycloneDX .NET tool or sbom-tool, then sbombox push
xUnit or NUnit in the SBOMTest projects includedAdd -t to dotnet-CycloneDX
Root component version 0.0.0No -sv passedPass -sv with your release version
Components with no versionNo lockfile, or a universal tool guessedCommit 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.