-
Benachrichtigungen
You must be signed in to change notification settings - Fork 68
/
set_version.ps1
26 lines (19 loc) · 903 Bytes
/
set_version.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
param(
[Parameter(Mandatory=$true)][string]$VersionStr
)
# Some basic validation
$Version = [System.Version]::Parse($VersionStr)
$CodeVersionPath = "$PSScriptRoot/CloudinaryDotNet/CloudinaryVersion.cs"
$CsProjPath = "$PSScriptRoot/CloudinaryDotNet/CloudinaryDotNet.csproj"
function Set-Version-In-Code($CodeVersionPath, $Version) {
$Text = [IO.File]::ReadAllText($CodeVersionPath) -replace "Full => `"\d+\.\d+\.?\d*`"", "Full => `"$Version`""
[IO.File]::WriteAllText($CodeVersionPath, $Text)
}
function Set-CsProj-Version($CsProjPath, $Version) {
$Text = [IO.File]::ReadAllText($CsProjPath)
$r = [regex]'<Version>\d+\.\d+\.?\d*</Version>'
$Text = $r.Replace($Text, "<Version>$Version</Version>", 1) # Replaces only the first occurrence
[IO.File]::WriteAllText($CsProjPath, $Text)
}
Set-Version-In-Code $CodeVersionPath $Version
Set-CsProj-Version $CsProjPath $Version