Skip to content

Instantly share code, notes, and snippets.

@jobou363
Created May 22, 2020 18:12
Show Gist options
  • Save jobou363/1a69c256fc96698baec7d9f4a441c3b3 to your computer and use it in GitHub Desktop.
Save jobou363/1a69c256fc96698baec7d9f4a441c3b3 to your computer and use it in GitHub Desktop.
Update a list of nuget package and set allowed versions to a range
Import-Module ".\psake\psake-v4.00\psake.psm1" -verbose -force -passthru
$nugetServerUrlPrerelease = "https://nuget.prerelease"
Write-Host "Update prerelease"
Write-Host "feed alpha : $nugetServerUrlPrerelease"
$packages = "Package1", "Package2"
$versionname = "4.8.0-alpha-JIRA-1000."
$version = "$versionname.56"
Foreach($p in $packages){
Write-Host "Update $p"
Exec { & ".nuget\nuget.exe" "update" "solution.sln" "-Id" "$p" "-Version" "$version" "-source" "$nugetServerUrlPrerelease" "-MSBuildVersion" "15.9" "-prerelease" "-FileConflictAction" "overwrite" "-NonInteractive" }
}
$items = Get-ChildItem packages.config -recurse
Foreach($item in $items){
Write-Host "Update $item"
$file = $item
[xml]$XmlDocument = Get-Content -Path $file
Foreach($p in $XmlDocument.packages.package){
#$p.Id
if($packages.Contains($p.Id))
{
Write-Host "update allowed version for {$($p.Id)}}"
$p.SetAttribute("allowedVersions", "($($versionname)1,$($versionname)1000)")
$p
}
}
$XmlDocument.Save($file)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment