PatchVersionPrefix.ps1 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env pwsh
  2. <#
  3. .SYNOPSIS
  4. Updates the version.props file in repos to a newer patch version
  5. .PARAMETER Repos
  6. A list of the repositories that should be patched
  7. #>
  8. [CmdletBinding()]
  9. param(
  10. [Parameter(Mandatory = $true)]
  11. [string[]]$Repos
  12. )
  13. $ErrorActionPreference = 'Stop'
  14. Import-Module -Scope Local -Force "$PSScriptRoot/common.psm1"
  15. function BumpPatch([System.Xml.XmlNode]$node) {
  16. if (-not $node) {
  17. return
  18. }
  19. [version] $version = $node.InnerText
  20. $node.InnerText = "{0}.{1}.{2}" -f $version.Major, $version.Minor, ($version.Build + 1)
  21. Write-Host "Changing $version to $($node.InnerText)"
  22. }
  23. foreach ($repo in $Repos) {
  24. $path = "$PSScriptRoot/../modules/$repo/version.props"
  25. Write-Host -ForegroundColor Magenta "Updating $repo"
  26. if (-not (Test-Path $path)) {
  27. Write-Warning "$path does not exist"
  28. continue
  29. }
  30. $path = Resolve-Path $path
  31. Write-Verbose "$path"
  32. [xml] $xml = LoadXml $path
  33. $suffix = $xml.SelectSingleNode('/Project/PropertyGroup/VersionSuffix')
  34. if (-not $suffix) {
  35. write-error "$path does not have VersionSuffix"
  36. }
  37. $versionPrefix = $xml.SelectSingleNode('/Project/PropertyGroup/VersionPrefix')
  38. $epxVersionPrefix = $xml.SelectSingleNode('/Project/PropertyGroup/ExperimentalProjectVersionPrefix')
  39. $exVersionPrefix = $xml.SelectSingleNode('/Project/PropertyGroup/ExperimentalVersionPrefix')
  40. BumpPatch $epxVersionPrefix
  41. BumpPatch $exVersionPrefix
  42. BumpPatch $versionPrefix
  43. SaveXml $xml $path
  44. }