Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trnktms/097834904a4fbcf4d616cc4ef57c177c to your computer and use it in GitHub Desktop.
Save trnktms/097834904a4fbcf4d616cc4ef57c177c to your computer and use it in GitHub Desktop.

Automation of creating nuget package updates in multiple repos

Use the commands in the following order

  1. create-branches.ps1
  2. upgrade-packages.ps1
  3. push-branches.ps1
##
## Be careful, because it's doing a git clean and git reset for all given repos!
## How to use: .\create-branches.ps1 -repos .\project-1,.\project-2 -branch feature/nuget-updates
##
param ([string[]] $repos, [string] $branch)
foreach ($repo in $repos) {
Write-Host "[Create-Branches] Creating branch for" $repo -ForegroundColor "Green"
Set-Location -Path $repo
git checkout master
git clean -fd
git reset --hard
git pull
git checkout -B $branch
git push -u origin $branch
cd..
}
##
## Prerequisite: dotnet tool install --global dotnet-outdated-tool
## How to use: .\upgrade-packages.ps1 -repos .\project-1,.\project-2
##
param ([string[]] $repos)
foreach ($repo in $repos) {
Write-Host "[Upgrade-Packages] Start to upgrade packages for" $repo -ForegroundColor "Green"
Set-Location -Path $repo
Write-Host "[Upgrade-Packages] Upgrade packages for" $repo -ForegroundColor "Green"
dotnet outdated --include my.custom.packages -u
Write-Host "[Upgrade-Packages] Build solution for" $repo -ForegroundColor "Green"
dotnet build
cd..
}
##
## Be careful, because it's commiting and pushing to all given repos!
## How to use: .\push-branches.ps1 -repos .\project-1,.\project-2 -commit "Update packages"
##
param ([string[]] $repos, [string] $commit)
foreach ($repo in $repos) {
Write-Host "[Push-Branches] Commit changes branch for" $repo -ForegroundColor "Green"
Set-Location -Path $repo
git add .
git commit -m $commit
git push
cd..
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment