|
| 1 | +################### |
| 2 | +## PS script to implement a semantic versioning change from (say) 8.0.x to 8.1 |
| 3 | +## across all interdependent cs packages |
| 4 | + |
| 5 | +## Wherever we have <Version>8.0.n</Version> replace it to <Version>8.1.0</Version> where n >= 0 |
| 6 | + |
| 7 | +## Wherever we have <PackageReference Include="cloudscribe.Anything" Version="8.0.*" /> replace it to <PackageReference Include="cloudscribe.Anything" Version="8.1.*" /> |
| 8 | + |
| 9 | +## Wherever we have <PackageReference Include="cloudscribe.Anything" Version="8.0.n" /> replace it to <PackageReference Include="cloudscribe.Anything" Version="8.1.0" /> where n >= 0 |
| 10 | + |
| 11 | +## Exclude cloudscribe.HtmlAgilityPack and DbHelpers because those ones are ancient and frozen |
| 12 | +################### |
| 13 | + |
| 14 | + |
| 15 | +# Define the directory containing the .csproj files |
| 16 | +$directory = "src" |
| 17 | + |
| 18 | +# Define the new version |
| 19 | +$newVersion = "8.1.0" |
| 20 | +$newWildcardVersion = "8.1.*" |
| 21 | + |
| 22 | +# Get all .csproj files in the directory and subdirectories |
| 23 | +$csprojFiles = Get-ChildItem -Path $directory -Recurse -Filter *.csproj |
| 24 | + |
| 25 | +foreach ($file in $csprojFiles) { |
| 26 | + # Read the content of the .csproj file |
| 27 | + $content = Get-Content -Path $file.FullName |
| 28 | + |
| 29 | + # Update the version of cloudscribe package references, except for cloudscribe.HtmlAgilityPack and cloudscribe.DbHelpers |
| 30 | + $updatedContent = $content -replace '(?<=<PackageReference Include="cloudscribe\.(?!HtmlAgilityPack|DbHelpers)[^"]+" Version=")8\.0\.\*', $newWildcardVersion |
| 31 | + $updatedContent = $updatedContent -replace '(?<=<PackageReference Include="cloudscribe\.(?!HtmlAgilityPack|DbHelpers)[^"]+" Version=")8\.0\.\d+', $newVersion |
| 32 | + |
| 33 | + # Update the <Version> element if it matches the 8.0.* pattern |
| 34 | + $updatedContent = $updatedContent -replace '<Version>8\.0\.\d+</Version>', "<Version>$newVersion</Version>" |
| 35 | + |
| 36 | + # Write the updated content back to the .csproj file |
| 37 | + Set-Content -Path $file.FullName -Value $updatedContent |
| 38 | + |
| 39 | + Write-Host "Updated $file.FullName" |
| 40 | +} |
| 41 | + |
| 42 | +Write-Host "All cloudscribe package references (except cloudscribe.HtmlAgilityPack and cloudscribe.DbHelpers) and <Version> elements have been updated to version $newVersion or $newWildcardVersion as appropriate." |
| 43 | + |
0 commit comments