Created
August 2, 2013 08:45
-
-
Save tjrobinson/6138411 to your computer and use it in GitHub Desktop.
Find NuGet packages across multiple solutions
This file contains 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
$packagesInUse = @() | |
[xml] $nugetConfig = [xml](Get-Content nuget.config) | |
[System.Xml.XmlElement] $nugetConfigRoot = $nugetConfig.get_DocumentElement() | |
$repositoryPath = $nugetConfigRoot.SelectSingleNode("repositoryPath").InnerText | |
Write-Host "repositoryPath:" $repositoryPath | |
[xml] $repositories = [xml](Get-Content $repositoryPath\repositories.config) | |
[System.Xml.XmlElement] $repositoriesRoot = $repositories.get_DocumentElement() | |
$packageConfigs = $repositoriesRoot.SelectNodes("repository") | |
foreach($packageConfig in $packageConfigs) | |
{ | |
$packagesConfigPath = $packageConfig.Attributes["path"].Value | |
[xml] $packagesConfig = [xml](Get-Content $repositoryPath\$packagesConfigPath) | |
[System.Xml.XmlElement] $packagesConfigRoot = $packagesConfig.get_DocumentElement() | |
$packages = $packagesConfigRoot.SelectNodes("package") | |
foreach($package in $packages) | |
{ | |
$packagesInUse = $packagesInUse + [string] ($package.Attributes["id"].Value + ", " + $package.Attributes["version"].Value + ", " + $packagesConfigPath.Replace("\packages.config","").Replace("..\","")) | |
} | |
} | |
foreach($packageInUse in $packagesInUse | Sort-Object) | |
{ | |
Write-Host $packageInUse | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment