Skip to content

Instantly share code, notes, and snippets.

@silverl
Forked from haacked/download-nuget-licenses.ps1
Last active May 16, 2023 16:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silverl/c945a494702c2469372b8be2ef95d319 to your computer and use it in GitHub Desktop.
Save silverl/c945a494702c2469372b8be2ef95d319 to your computer and use it in GitHub Desktop.
A PowerShell script to download your NuGet package licenses as first seen in http://haacked.com/archive/2015/03/28/download-nuget-package-licenses/
Split-Path -parent $dte.Solution.FileName | cd
New-Item -ItemType Directory -Force -Path ".\licenses"
@( Get-Project -All | ? { $_.ProjectName } | % { Get-Package -ProjectName $_.ProjectName } ) | Sort -Unique Id | % { $pkg = $_ ; Try { (New-Object System.Net.WebClient).DownloadFile($pkg.LicenseUrl, (Join-Path (pwd) 'licenses\') + $pkg.Id + ".html") } Catch [system.exception] { Write-Host "Could not download license for $($pkg.Id)" } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment