Skip to content

UpdateCommand: try resolve license code by the license file conent#71

Merged
max-ieremenko merged 1 commit intorelease/3.4.0from
feature/license-by-content-resolver
Sep 2, 2023
Merged

UpdateCommand: try resolve license code by the license file conent#71
max-ieremenko merged 1 commit intorelease/3.4.0from
feature/license-by-content-resolver

Conversation

@max-ieremenko
Copy link
Owner

If a license code is not defined in a package, but the package contains a license file:

  1. Check other versions of this package in the repository
    If the other version contains an identical license file, copy the license code with the description The license file is identical to the file from version {Version}

  2. Check repository license files
    If the license is defined with an identical license file, copy the license code with the description The license file is identical to the {Code} license file.

As an example nuget package Microsoft.NET.Test.Sdk

Spec contains only LICENSE_NET.txt:

<package>
  <metadata>
    <id>Microsoft.NET.Test.Sdk</id>
    <version>17.6.3</version>
    <license type="file">LICENSE_NET.txt</license>
  </metadata>
</package>

When the first time the package appears in the repository, a license ms-net-library cannot be resolved automatically. The license code should be updated manually.

index.json

{
  "License": {
    "Code": "ms-net-library",
  },
  "Licenses": [
    {
      "Subject": "package",
      "Code": null,
      "HRef": "LICENSE_NET.txt"
    }
  ]
}

Update Microsoft.NET.Test.Sdk from version 17.6.3 to 17.7.2. Version 17.7.2 as well contains only LICENSE_NET.txt:

<package>
  <metadata>
    <id>Microsoft.NET.Test.Sdk</id>
    <version>17.7.2</version>
    <license type="file">LICENSE_NET.txt</license>
  </metadata>
</package>

The content of LICENSE_NET.txt in 17.7.2 is identical to 17.6.3, so the tool automatically assigns ms-net-library license code for version 17.7.2:

{
  "License": {
    "Code": "ms-net-library",
  },
  "Licenses": [
    {
      "Subject": "package",
      "Code": "ms-net-library",
      "HRef": "LICENSE_NET.txt",
      "Description": "The license file is identical to the file from version 17.6.3"
    }
  ]
}

@max-ieremenko max-ieremenko merged commit 71c9e7e into release/3.4.0 Sep 2, 2023
@max-ieremenko max-ieremenko deleted the feature/license-by-content-resolver branch September 2, 2023 12:38
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.

1 participant