Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuget <licenseUrl> is deprecated #983

Open
blumendorf opened this issue May 3, 2023 · 1 comment
Open

nuget <licenseUrl> is deprecated #983

blumendorf opened this issue May 3, 2023 · 1 comment

Comments

@blumendorf
Copy link

We saw a couple of urls like this for our .net projects: https://aka.ms/deprecateLicenseUrl

This is related to the <licenseUrl> tag being deprecated and microsoft using the <license> tag instead: NuGet/Announcements#32

See https://www.nuget.org/packages/HotChocolate for an example.

The new license tag looks like this
<license type="expression">MIT</license> or <license type="file">LICENSE.txt</license>

So, I believe that the nuspec_license_urls method in the nuget package manager needs to be changed.

Unfortunately, I have never used ruby, so I am having trouble making a PR.
I also had trouble fully understanding the matcher logic.
Here is some rough idea, but it probably needs a slightly more sophisticated approach.

    def self.nuspec_license_urls(filepath)
      content = File.read(filepath)
      dir = File.dirname(filepath)
      xml = REXML::Document.new(content)
      licenses = REXML::XPath.match(xml, '//metadata//license')

      # if no licenses are found, fallback to licenseUrl
      if (licenses.length == 0)
        return REXML::XPath.match(xml, '//metadata//licenseUrl')
                  .map(&:get_text)
                  .map(&:to_s)
      end

      licenses.map do |license|
        type = license.attributes['type']

        if type == 'expression'
          # return the expressions directly
          license.get_text.to_s

        elsif type == 'file'
          # read the file and do something useful with it
          license_file_name = license.get_text.to_s.strip
          license_file = File.join(dir, license_file_name)
          if File.exist?(license_file)
            file_content = File.read(license_file).strip
            # not sure what to do here, since I could not get this to work with the matcher
          else
            # log an error and return something empty
          end
        end
      end
    end

I am not capable of producing a PR for this, but I am happy to team up with anyone willing to tackle this.

@cf-gitbot
Copy link
Collaborator

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants