Created
April 22, 2020 06:53
-
-
Save musukvl/5be7d02bbe83d00aa70a286a18b967a1 to your computer and use it in GitHub Desktop.
Generates nuget install for all references
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
# place this file to your prepository root, or set the your repository full path to $repositoriesRoot | |
$repositoriesRoot = Convert-Path . | |
$files = Get-ChildItem -Path $repositoriesRoot -Filter *.csproj -Recurse -File -Name | |
$commands = @() | |
foreach ($fileName in $files) { | |
$xml = [Xml](Get-Content "$repositoriesRoot\$fileName") | |
foreach ($item in $xml.SelectNodes("//PackageReference")) { | |
$attr = $item.Attributes["Include"] | |
$name = $attr.Value; | |
$versionAttr = $item.Attributes["Version"] | |
$version = "" | |
if (!$versionAttr) { | |
$versionNode = $item.SelectSingleNode("Version"); | |
$version = $versionNode.InnerText; | |
} | |
else { | |
$version = $versionAttr.Value | |
} | |
$commands += "nuget install $name -Version $version" | |
} | |
} | |
$commands = $commands | Sort-Object | Get-Unique | |
Write-Output $commands |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment