Safeguard
Security Guides•

How do NuGet packages declare licenses in a nuspec file?

NuGet uses a license element holding an SPDX expression or a path to a license file. licenseUrl is deprecated. Learn how to audit .NET package licenses.

Safeguard Security Team
3 min read

A NuGet package declares its license in the nuspec license element, either as an SPDX expression such as MIT or BSD-2-Clause OR MIT, or as a path to a license file packaged inside it. The older licenseUrl element is deprecated, so a scanner that relies on it will miss newer packages.

What the nuspec reference says

The license element is supported from NuGet 4.9.0. It holds an SPDX license expression or a path to a license file in the package. For common licenses, the documentation tells authors to use the SPDX identifier. For several licenses it allows a composite expression with operators such as OR. If the license is custom, the author packages a text or Markdown file and points to it.

nuget.org accepts only license expressions approved by the Open Source Initiative or the Free Software Foundation, according to the reference. The expression grammar also allows WITH for exceptions and the UNLICENSED value.

The requireLicenseAcceptance element is separate. It tells the client whether to prompt the consumer to accept the license before installing.

Reading each form

Nuspec contentMeaningAudit action
license type expression, MITOne SPDX licenseMatch to policy
license type expression, A OR BChoiceRecord your choice
license type fileCustom text inside the packageRead the file
licenseUrl onlyLegacy pointer to a web pageFetch and read, treat as lower confidence
UNLICENSEDNo rights grantedDo not use without permission

Audit steps for a .NET solution

  1. Restore packages and list all of them, including transitive ones.
  2. Read the nuspec inside each package, since it ships with the package.
  3. Normalize expressions and apply your policy tiers. See allow, review, deny tiers.
  4. For file type licenses, read the text and send unfamiliar terms to review.
  5. For licenseUrl only packages, fetch the page, save the text, and note the date, since web pages change.
  6. Ship notices for the packages you distribute.

Why the web link is weak

A URL can change or disappear after you approve a package. Prefer the license text that travels inside the package.

Try it yourself

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

Open a few components and see what license data an inventory holds for each.

Safeguard scans dependencies and builds SBOMs, and a free scan shows how it reads a project.

Quick check

Is licenseUrl still valid?

The reference marks it deprecated and says to use the license element instead.

Does requireLicenseAcceptance mean the license was reviewed?

No. It only makes the client prompt the consumer. Your own review is separate.

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.