File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
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."
You can’t perform that action at this time.
0 commit comments