A .NET tool to collect and analyze NuGet package licenses in a solution.
- License Analysis: Automatically detects and analyzes NuGet package licenses across all projects in a solution
- Multiple Output Formats: Supports both text and JSON output formats
- Comprehensive Reports: Generates detailed reports with package information and license details
- Cross-Platform: Works on Windows, macOS, and Linux
- Global Tool: Install once and use anywhere via command line
dotnet tool install -g EXCEEDSYSTEM.NuGetLicenseCollectorgit clone https://github.com/exceedsystem/NuGetLicenseCollector.git
cd NuGetLicenseCollector
dotnet pack
dotnet tool install -g --add-source ./bin/Debug EXCEEDSYSTEM.NuGetLicenseCollectordotnet tool uninstall -g EXCEEDSYSTEM.NuGetLicenseCollectorAfter uninstalling, you may want to delete the cache folder to free up disk space:
Windows:
rmdir /s "%USERPROFILE%\.exceedsystem\NuGetLicenseCollector"macOS/Linux:
rm -rf ~/.exceedsystem/NuGetLicenseCollectornuget-license-collector path/to/your/solution.slnnuget-license-collector path/to/your/project.csprojnuget-license-collector <input> [options]input- Path to the solution file (.sln) or project file (.csproj, .vbproj)
-o, --output <output>- Output file path (default: "nuget-licenses.txt")-j, --json- Output in JSON format-f, --force-refresh- Clear license cache and download fresh license texts--help- Show help information--version- Show version information
nuget-license-collector MySolution.slnnuget-license-collector MyProject.csprojnuget-license-collector MySolution.sln --jsonnuget-license-collector MySolution.sln -o licenses-report.txtnuget-license-collector MySolution.sln -j -o my-licenses.jsonnuget-license-collector MySolution.sln --force-refreshThe default text format provides a human-readable report with:
- Package name and version
- Author information
- License type and full license text
- Project URL and license URL (if available)
- License summary grouped by license type
The JSON format provides structured data suitable for further processing:
{
"packages": [
{
"name": "PackageName",
"version": "1.0.0",
"author": "Author Name",
"licenseType": "MIT",
"licenseText": "License text content...",
"licenseUrl": "https://...",
"projectUrl": "https://..."
}
],
"summary": {
"totalPackages": 10,
"generatedAt": "2023-12-01T12:00:00Z"
}
}- .NET 8.0 or later
- Solution file (.sln) or project file (.csproj, .vbproj) with valid NuGet package references
- Input Analysis: Parses the solution file (.sln) to discover all projects, or analyzes a single project file (.csproj, .vbproj)
- Package Discovery: Analyzes project assets (
obj/project.assets.json) to find NuGet package references - License Retrieval: Connects to NuGet.org to retrieve package metadata and license information with intelligent caching
- Report Generation: Creates comprehensive reports in the specified format
- Intelligent Caching: Licenses are cached locally for 30 days to improve performance
- Multiple Formats: Supports RTF, HTML, and plain text license formats
- Deduplication: Automatically deduplicates packages across multiple projects
- Network Resilience: Implements retry logic for NuGet API calls
- Cross-Platform: Works on Windows, macOS, and Linux
Contributions are welcome! Please feel free to submit a Pull Request.
See CHANGELOG.md for a detailed history of changes to this project.
This project is licensed under the MIT License - see the LICENSE file for details.
- "File not found" - Ensure the path to the solution or project file is correct
- "Unsupported file type" - Only .sln, .csproj, and .vbproj files are supported
- "No packages found" - Verify that your projects have NuGet package references and have been restored with
dotnet restore - Network errors - Check your internet connection as the tool needs to access NuGet.org
- MSBuild errors - Ensure the project is in a valid state and can be built
If you encounter any issues or have questions, please open an issue on the GitHub repository.