Skip to content

Instantly share code, notes, and snippets.

@jrotello
Last active August 29, 2015 14:10
Show Gist options
  • Save jrotello/dadb019445b7a43fc4a3 to your computer and use it in GitHub Desktop.
Save jrotello/dadb019445b7a43fc4a3 to your computer and use it in GitHub Desktop.
Recursively find the packages.config files and generate a unique list of all the Nuget packages in use.
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
$Path
)
$packages = @()
ls -Path $Path -Include packages.config -Recurse -File | % {
$xml = [xml](Get-Content $_)
$xml.packages.package | % {
$url = "https://www.nuget.org/packages/{0}" -f $_.id
$downloadUrl = "https://www.nuget.org/api/v2/package/{0}/{1}" -f $_.id, $_.version
Add-Member -NotePropertyName Url -NotePropertyValue $url -InputObject $_
Add-Member -NotePropertyName DownloadUrl -NotePropertyValue $downloadUrl -InputObject $_
if (-not $packages.Contains($downloadUrl)) {
$packages += $downloadUrl
Write-Output $_
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment