Fix #4609: Handle file-type license references in NuGet packages #4701
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #4609: Handle file-type license references in NuGet packages
Detect
<license type='file'>in .nuspec files and extract file path tolicense_file_referencesfield. Keepextracted_license_statementas raw path value to integrate with existing license resolution inprocess_codebasefunction.This follows the two-phase architecture pattern:
process_codebaseresolves file referencesMinimal changes (37 lines) following maintainer feedback from PR #4689.
Fixes #4609
Changes Made
Problem
NuGet packages with
<license type="file">path/LICENSE.txt</license>were returningLicenseRef-scancode-unknownbecause the file-type license references were not being extracted.Solution
license_file_referencesfield toNugetNuspecHandler@type="file"in nuspec XMLextracted_license_statementandlicense_file_referencesFiles Changed
src/packagedcode/nuget.py- Core implementation (21 lines added)tests/packagedcode/test_nuget.py- New test case (8 lines added)tests/packagedcode/data/nuget/license_file.nuspec- Test fixture (new file).expectedtest files - Updated withlicense_file_referencesfield (1 line each)Testing
✅ All existing tests pass (11 passed in 7.91s)
✅ New test
test_nuget_parse_license_file_referencevalidates license file extractionTasks
fix-4609-nuget-license-file-v4) and has no merge conflicts 📁Implementation Details
Code Changes in
src/packagedcode/nuget.py:Why This Works
process_codebasefunction will handle file resolution using the stored pathsSigned-off-by: Jayant jayantmcom@gmail.com