Safeguard
Developer Tools•

How do you generate an SBOM for a .NET project?

Use the CycloneDX .NET global tool on a solution or project file, choose JSON and a spec version, and exclude test projects and dev only packages.

Safeguard Security Team
3 min read

To generate an SBOM for a .NET project, install the CycloneDX .NET global tool, then point it at your solution or project file and choose an output folder. It writes a CycloneDX file in JSON or XML. Pointed at a solution, it aggregates every project in it into one document.

Steps

  1. Install the tool: dotnet tool install with the global option and the package name CycloneDX.
  2. If the command is not found, restart the terminal and check that the dotnet tools folder in your home directory is on your PATH.
  3. Run it against the solution.
dotnet-CycloneDX MyApp.sln -o ./sbom -F Json
  1. For a single project file, add the recursive project reference option so referenced projects are scanned too.
  2. Validate the output and store it with the build.

What you can point it at

Accepted inputs include solution files, C#, F# and VB project files, packages.config, and a directory. A directory is scanned recursively for packages.config files only, so a modern SDK style repo should be pointed at a solution or project file instead.

Settings worth setting on purpose

ConcernDefaultWhat to do
Output formatAutoChoose Json explicitly if your tooling expects it
Spec version1.7Lower it if a downstream tool rejects the newest version
Test and dev packagesIncluded, marked with scope excludedSkip test projects, or filter dev only packages
Target frameworkAll, aggregatedLimit to one framework if you ship one
Package restoreRunsDisable only if restore already ran

The scope marking is useful. An excluded scope tells a reader the package is not shipped, which reduces false alarms later.

The GitHub license lookup trap

The tool can look up licenses through GitHub. Unauthenticated, that is limited to 60 calls per hour, and the project says BOM generation fails if you hit the limit. Supply a token in CI or leave the lookup off. The lookup also only covers master branch license references, so treat results as a hint.

In containers

If you run the tool from its Docker image, pass your user and group IDs so restore can write to the mounted volume and output files are not owned by root.

Try it yourself

Click through it at your own pace, or open it full screen.

Check how each component shows its version and ecosystem, the same fields a NuGet package needs in an SBOM.

Quick check

Should test projects be in a shipped SBOM?

Usually not. Exclude them, or keep them marked as excluded scope so readers can tell them apart.

Why did generation fail only in CI?

A common cause is the unauthenticated GitHub license lookup hitting its hourly limit. Use a token or disable it.

Safeguard's SBOM and dependency scanning can read the CycloneDX file this produces, and a free scan is at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.