Skip to content

Commit a838800

Browse files
committed
add update-versions.ps1 script
1 parent 8f46b53 commit a838800

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

update-versions.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
param(
2+
[string] $version
3+
)
4+
5+
function Set-Versions($content, $versionToSet) {
6+
7+
8+
$newContent = [regex]::replace($content,'<PackageReference Include="(?<packageName>Reqnroll[^"]*)" Version="(?<version>[^"]*)" />', {
9+
param($m)
10+
$m.Value.Replace($m.Groups["version"].Value, $versionToSet)
11+
})
12+
return $newContent
13+
}
14+
15+
if (-not $version) {
16+
Write-Error "Error. The version was not specified."
17+
Write-Error "Usage:"
18+
Write-Error " update-versions.ps1 [version]"
19+
Exit
20+
}
21+
22+
$projectFiles = Get-ChildItem -Path $PSScriptRoot -File -Recurse -Filter '*.csproj'
23+
$changedCount = 0
24+
foreach ($path in $projectFiles){
25+
$fileContent = Get-Content -LiteralPath $path -Raw
26+
$newFileContent = Set-Versions $fileContent $version
27+
if ($newFileContent -ne $fileContent){
28+
Write-Host "Updating $($path.Name)"
29+
Set-Content -Path $path -Value $newFileContent -NoNewline -Encoding utf8
30+
$changedCount++
31+
}
32+
}
33+
34+
Write-Host "Updated $changedCount files."

0 commit comments

Comments
 (0)