eclipse-dash / dash-licenses

Extract license information from content.
http://projects.eclipse.org/projects/technology.dash
Eclipse Public License 2.0
47 stars 33 forks source link

dotnet instructions feedback #341

Open martafullen opened 4 months ago

martafullen commented 4 months ago

We used the tool to check licenses of our dotnet project and would like to give you our feedback to the instructions provided in readme here:

https://github.com/eclipse/dash-licenses?tab=readme-ov-file#example-net

The command didn't quite work for us so we dug in and figured it out. Here's our feedback and solution for a dotnet project, using PowerShell 7.4.2 on Windows 11.

  1. grep and sed are not available out of the box on Windows (cmd/powershell). A simple workaround is to use the binaries that come with git. (tip: Set-Alias in powershell makes things easier)

    With git installed under C:\Program Files\Git we can use C:\"Program Files"\Git\usr\bin\grep.exe and C:\"Program Files"\Git\usr\bin\sed.exe.

  2. the regex didn't quite work for us, needed to make minor changes (depends on the flavour used by the binary and powershell I guess). This worked for us using the git sed binary under powershell :

    sed -E -e 's/\s+> ([a-zA-Z0-9\.\_\-]+)\s+([0-9]+\.[0-9]+\.[0-9]+).*/nuget\/nuget\/\-\/\1\/\2/g'
  3. It is stated in the readme but can easily be overlooked by non-java developers ;) dash-licenses requires java SDK and not JRE (which is easier to come across). We got version 22 from https://jdk.java.net/22/

  4. Finally, the tested powershell commands (broken up into several steps):

    dotnet restore
    
    # filters packages and writes into packages-filtered.txt
    dotnet list package --include-transitive | Select-String -Pattern '>' | Select-String -Pattern '\s(Microsoft|NETStandard|NuGet|System|runtime)' -NotMatch | Out-file -FilePath 'packages.txt'
    
    # runs the replacement and dash-licences on the filtered package list
    # prints output to console and a summary to output.txt
    cat packages.txt | sed -E -e 's/\s+> ([a-zA-Z0-9\.\_\-]+)\s+([0-9]+\.[0-9]+\.[0-9]+).*/nuget\/nuget\/\-\/\1\/\2/g' | java -jar org.eclipse.dash.licenses-1.0.2.jar - | Out-file -FilePath 'output.txt'

That's it. If you like, we could propose changes in a merge request, but feel free to copypaste from here.