4

Is there a tool or script that can pull libraries and its license(s) in a single file?

Input: root source folder

C:\src\project_bananna

Output: text file, perhaps in csv format

+----------------------------+----------+-------------+
|       NuGet package        | Version  |  Licenses   |
+----------------------------+----------+-------------+
| JQuery                     | 1.4      | MIT License |
| Json.NET                   | 7        | MIT License |
| ...                        | ...      | ...         |
+----------------------------+----------+-------------+
2

This is as far as I could get using the Package Manager Console.

The Package Manager Console is a PowerShell console within Visual Studio used to interact with NuGet and automate Visual Studio.

The only problem is that, for what I've seen, there's no (easy) way to get the license type as you'd like, just the license URL. In any case, this gives you an idea to get started with something and might be sufficient for your purpose.

I've used the Get-Package cmdlet: open the Package Manager Console and type the following, replacing OUTPUT_CSV with the path and name of the output CSV file you want to create:

Get-Package | Select-Object Id,Version,LicenseUrl | Export-Csv OUTPUT_CSV -NoTypeInformation

I've tested it with a random project of mine, and this is the content of the output CSV file:

"Id","Version","LicenseUrl"
"Google.Apis","1.9.1","http://www.apache.org/licenses/LICENSE-2.0"
"Google.Apis.Auth","1.9.0","http://www.apache.org/licenses/LICENSE-2.0"
"Google.Apis.Core","1.9.1","http://www.apache.org/licenses/LICENSE-2.0"
"Google.Apis.YouTube.v3","1.9.0.1360","http://www.apache.org/licenses/LICENSE-2.0"
"log4net","2.0.3","http://logging.apache.org/log4net/license.html"
"Microsoft.Bcl","1.1.9","http://go.microsoft.com/fwlink/?LinkId=329770"
"Microsoft.Bcl.Async","1.0.168","http://go.microsoft.com/fwlink/?LinkId=329770"
"Microsoft.Bcl.Build","1.0.14","http://go.microsoft.com/fwlink/?LinkId=329770"
"Microsoft.Net.Http","2.2.28","http://go.microsoft.com/fwlink/?LinkId=329770"
"Newtonsoft.Json","6.0.8","https://raw.github.com/JamesNK/Newtonsoft.Json/master/LICENSE.md"
"Zlib.Portable","1.10.0","http://en.wikipedia.org/wiki/Zlib_License"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.