Powershell script for updating nuget packages
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