Last active
August 29, 2015 14:10
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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