1515# Define the directory containing the .csproj files
1616$directory = " src"
1717
18- # Define the new version
19- $newVersion = " 8.1.0"
20- $newWildcardVersion = " 8.1.*"
18+ # Define the old & new versions
19+ $oldVersion = ' 8\.1' # slash needed !
20+ $newVersion = " 8.2.0"
21+ $newWildcardVersion = " 8.2.*"
22+
2123
2224# Get all .csproj files in the directory and subdirectories
2325$csprojFiles = Get-ChildItem - Path $directory - Recurse - Filter * .csproj
@@ -27,11 +29,18 @@ foreach ($file in $csprojFiles) {
2729 $content = Get-Content - Path $file.FullName
2830
2931 # 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+ $wildCardPattern = ' (?<=<PackageReference Include="cloudscribe\.(?!HtmlAgilityPack|DbHelpers)[^"]+" Version=")' + $oldVersion + ' \.\*'
34+ $updatedContent = $content -replace $wildCardPattern , $newWildcardVersion
35+
36+ $digitPattern = ' (?<=<PackageReference Include="cloudscribe\.(?!HtmlAgilityPack|DbHelpers)[^"]+" Version=")' + $oldVersion + ' \.\d+'
37+ $updatedContent = $updatedContent -replace $digitPattern , $newVersion
38+
39+ # Update the <Version> element if it matches the pattern
40+ $versionPattern = ' <Version>' + $oldVersion + ' \.\d+</Version>'
41+ $replacement = " <Version>$newVersion </Version>"
42+ $updatedContent = $updatedContent -replace $versionPattern , $replacement
3243
33- # Update the <Version> element if it matches the 8.0.* pattern
34- $updatedContent = $updatedContent -replace ' <Version>8\.0\.\d+</Version>' , " <Version>$newVersion </Version>"
3544
3645 # Write the updated content back to the .csproj file
3746 Set-Content - Path $file.FullName - Value $updatedContent
0 commit comments