Skip to content

Commit 42eba23

Browse files
Add set_version.ps1 helper script
1 parent e9924f8 commit 42eba23

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

set_version.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
param(
2+
[Parameter(Mandatory=$true)][string]$VersionStr
3+
)
4+
5+
# Some basic validation
6+
$Version = [System.Version]::Parse($VersionStr)
7+
8+
$NuspecPath = "$PSScriptRoot/CloudinaryDotNet.nuspec"
9+
10+
$CsProjPaths = @(
11+
"$PSScriptRoot/Cloudinary/Cloudinary.csproj",
12+
"$PSScriptRoot/Core/CloudinaryDotNet.Core.csproj"
13+
)
14+
15+
function Set-Nuspec-Version($NuspecPath, $Version) {
16+
$Text = [IO.File]::ReadAllText($NuspecPath) -replace "<version>\d+\.\d+\.?\d*</version>", "<version>$Version</version>"
17+
[IO.File]::WriteAllText($NuspecPath, $Text)
18+
}
19+
20+
function Set-CsProj-Version($CsProjPath, $Version) {
21+
$Text = [IO.File]::ReadAllText($CsProjPath) `
22+
-replace "<Version>\d+\.\d+\.?\d*</Version>", "<Version>$Version</Version>" `
23+
-replace "<FileVersion>\d+\.\d+\.?\d*</FileVersion>", "<FileVersion>$Version</FileVersion>"
24+
[IO.File]::WriteAllText($CsProjPath, $Text)
25+
}
26+
27+
Set-Nuspec-Version $NuspecPath $Version
28+
29+
foreach ($CsProjPath in $CsProjPaths) {
30+
Set-CsProj-Version $CsProjPath $Version
31+
}

0 commit comments

Comments
 (0)