Created
July 14, 2017 16:51
-
-
Save richardnagle/2ffa63c3a9a711aa97c929192d8cbcef to your computer and use it in GitHub Desktop.
Powershell script for updating nuget packages
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
Param( | |
[string]$nugetTarget, | |
[string]$nugetUrl | |
) | |
Write-Host "Getting installed packages from packages.configs" | |
$installedPackages = Get-ChildItem -path '.' -Recurse -Include 'packages.config' | | |
Select-Xml -xpath '//package/@id' | | |
Select-Object -ExpandProperty Node | | |
Select-Object -ExpandProperty value | | |
Sort-Object -Unique | |
Write-Host "Getting available update from $nugetUrl" | |
$availablePackages = nuget list -source $nugetUrl | | |
foreach {$_.Split(' ')[0]} | |
Write-Host "Updating NuGetPackages" | |
$nugetExeIdArgs = @() | |
$installedPackages | | |
where {$availablePackages -contains $_} | | |
ForEach-Object { | |
Write-Host("Updating $_") | |
$nugetExeIdArgs += "-Id" | |
$nugetExeIdArgs += $_ | |
} | |
$nuget = 'nuget.exe' | |
$arguments = "update", $nugetTarget, "-Source", $nugetUrl, "-Source", "https://api.nuget.org/v3/index.json" | |
$arguments += $nugetExeIdArgs | |
&$nuget $arguments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment