Skip to content

feat: NuGet license file support + license expression fixes#1076

Merged
mtsfoni merged 8 commits into
masterfrom
feature/nuget-license-files
Apr 26, 2026
Merged

feat: NuGet license file support + license expression fixes#1076
mtsfoni merged 8 commits into
masterfrom
feature/nuget-license-files

Conversation

@mtsfoni
Copy link
Copy Markdown
Member

@mtsfoni mtsfoni commented Apr 19, 2026

Summary

This PR adds proper support for NuGet packages that declare their license as a file (rather than a URL or SPDX expression), and fixes two related issues in license handling.

Closes #915. Supersedes #1011.

Changes

Added

  • NuGet <license type="file"> support — when --include-license-text is specified, the license file content is embedded as base64-encoded text in the BOM. Without the flag the license is detected but not embedded.

Fixed

  • Suppress aka.ms/deprecateLicenseUrl stub URL — NuGet auto-injects https://aka.ms/deprecateLicenseUrl into <licenseUrl> for packages packed with <license type="file"> for old-client compatibility. This stub is now ignored in both the GitHub and no-GitHub code paths rather than being emitted as a bogus license entry. See NuGet packaging spec.
  • Fix UNLICENSED emitted as SPDX id (fixes Nuget UNLICENSED License Expression Produces Invalid File #915, from Fix #915: handle UNLICENSED in NuGet license expressions #1004) — UNLICENSED is a NuGet-specific token and not a valid SPDX identifier. It is now emitted as license.name instead of license.id.
  • Fix null-URL license stub — packages with no <licenseUrl> no longer produce a spurious License { Name="Unknown - See URL", Url=null } node. Note: name + url is valid per the CycloneDX spec (name satisfies the required id/name choice, url is optional), but emitting this for packages with no license declared at all is semantically incorrect — it is fabricated data. Packages with a real, non-stub licenseUrl still get Unknown - See URL emitted as before.

Notes

@mtsfoni mtsfoni requested a review from a team as a code owner April 19, 2026 22:21
mus65 and others added 6 commits April 27, 2026 00:44
Signed-off-by: Marius Thesing <marius.thesing@gmail.com>
Signed-off-by: Michael Tsfoni <80639729+mtsfoni@users.noreply.github.com>
Signed-off-by: Marius Thesing <marius.thesing@gmail.com>
Signed-off-by: Michael Tsfoni <80639729+mtsfoni@users.noreply.github.com>
Adds --include-license-text CLI option that controls whether license file
contents are embedded as base64 in the BOM. Fixes null-URL stub emission
for packages with no license URL. aka.ms/deprecateLicenseUrl guard still
missing (1 unit test + 1 E2E test expected to fail).

Signed-off-by: Michael Tsfoni <80639729+mtsfoni@users.noreply.github.com>
… file support

- Skip https://aka.ms/deprecateLicenseUrl stub URL in both the GitHub
  and no-GitHub code paths to avoid spurious API calls and incorrect
  license nodes (NuGet auto-injects this URL for old-client compat when
  packing <license type="file"> packages)
- Add unit test covering the GitHub-path guard
- Update docs/license-resolution.md Phase 4 description
- Add [Unreleased] CHANGELOG entries for license file support and fixes

Signed-off-by: Michael Tsfoni <80639729+mtsfoni@users.noreply.github.com>
Signed-off-by: Lakshya Jain <lakshyajain1995@gmail.com>
Signed-off-by: Michael Tsfoni <80639729+mtsfoni@users.noreply.github.com>
Signed-off-by: Michael Tsfoni <80639729+mtsfoni@users.noreply.github.com>
@mtsfoni mtsfoni force-pushed the feature/nuget-license-files branch from c0a647d to 85cc562 Compare April 26, 2026 22:44
mtsfoni added 2 commits April 27, 2026 00:59
- Remove spurious 'Unknown - See URL' license nodes for packages with
  no license declared (was valid per CycloneDX spec but semantically
  incorrect - emitting fabricated data)
- Reflects new behaviour introduced by nuget license file support

Signed-off-by: Michael Tsfoni <80639729+mtsfoni@users.noreply.github.com>
Signed-off-by: Michael Tsfoni <80639729+mtsfoni@users.noreply.github.com>
@mtsfoni mtsfoni merged commit 71aa60e into master Apr 26, 2026
16 of 17 checks passed
mtsfoni added a commit that referenced this pull request Apr 26, 2026
…ling changes

Master PR #1076 (feature/nuget-license-files) refactored license emission
so that packages with no licenseUrl/expression no longer emit empty
<licenses><name>Unknown - See URL</name></licenses> blocks. Regenerate
the ConditionalPackageSnapshotTests verified files against current
master to match.

Signed-off-by: Michael Tsfoni <80639729+mtsfoni@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nuget UNLICENSED License Expression Produces Invalid File

3 participants