Skip to content

Improve declared license collection from nuspec files (#2669) - #5271

Open
teyesan wants to merge 6 commits into
aboutcode-org:developfrom
teyesan:improve-declared-license-detection
Open

Improve declared license collection from nuspec files (#2669)#5271
teyesan wants to merge 6 commits into
aboutcode-org:developfrom
teyesan:improve-declared-license-detection

Conversation

@teyesan

@teyesan teyesan commented Aug 17, 2026

Copy link
Copy Markdown

Description

Improve NuGet .nuspec license handling to correctly process the different ways license information can be declared.

Changes

  • Handle <license type="expression"> as the package's declared license expression.
  • Handle <license type="file"> as a reference to a license file and store the filename in extra_data["license_file"].
  • Preserve support for the legacy <licenseUrl> field when no <license> element is present.
  • Ignore NuGet's deprecated placeholder licenseUrl (https://aka.ms/deprecateLicenseUrl).
  • Update NuGet package test fixtures and expected results to cover license expressions and license files.

License precedence

When <license type="expression"> is present, the SPDX expression is used as the declared license statement.

When <license type="file"> is present, the referenced filename is stored separately in extra_data["license_file"], since it's a reference rather than license text itself, not the declared license statement directly.

A real (non-deprecated) <licenseUrl> is still treated as meaningful license information: it fills in the declared license statement when nothing else is available, or is appended alongside an SPDX expression when both are present. This preserves useful license info from licenseUrl rather than discarding it whenever a <license> element also exists.

NuGet's deprecated placeholder value (https://aka.ms/deprecateLicenseUrl) is always ignored, regardless of what else is present.

Fixes #2669

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@teyesan there are no test files for your tests.

Comment thread tests/packagedcode/test_nuget.py Outdated
@teyesan

teyesan commented Aug 19, 2026

Copy link
Copy Markdown
Author

Two tests are designed to fail currently and will pass once fix has been pushed.

@teyesan
teyesan force-pushed the improve-declared-license-detection branch from 9eba4de to c9ea9fb Compare August 19, 2026 20:56
@teyesan teyesan changed the title Updated Tests for Nuget Fix for issue declared license collection from nuspec (#2669) Aug 20, 2026
@teyesan
teyesan force-pushed the improve-declared-license-detection branch from 6df7db8 to bded38b Compare August 21, 2026 02:07
@teyesan teyesan changed the title Fix for issue declared license collection from nuspec (#2669) Improve declared license collection from nuspec files (#2669) Aug 21, 2026
@teyesan
teyesan force-pushed the improve-declared-license-detection branch 2 times, most recently from a2a8c5d to 9d35a92 Compare August 27, 2026 02:22
teyesan and others added 5 commits August 27, 2026 21:02
Signed-off-by: Temi Eyesan <teyesan06@icloud.com>
Signed-off-by: Temi Eyesan <teyesan06@icloud.com>
…helper function

Signed-off-by: tram-tr <htrinh@nd.edu>
…ction

Signed-off-by: Temi Eyesan <teyesan06@icloud.com>
@teyesan
teyesan force-pushed the improve-declared-license-detection branch 2 times, most recently from aa4cf99 to 7fd01d5 Compare August 28, 2026 02:31
Signed-off-by: teyesan <teyesan06@icloud.com>
@teyesan
teyesan marked this pull request as ready for review August 29, 2026 11:28
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.

Improve declared license collection from nuspec

3 participants