-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathversion.ps1
22 lines (18 loc) · 996 Bytes
/
version.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
param(
[string]$dir = "$pwd\ChocolateStoreCore"
)
$csprojPath = "$dir\ChocolateStoreCore.csproj"
$nuspecPath = "$dir\..\ChocolateyPackages\chocolatestore\chocolatestore.nuspec"
$version = Get-Content "$dir\..\version.txt"
$versionParts = $version.Split('.')
$buildNumber = [int]$versionParts[3]
$buildNumber++
$versionParts[3] = $buildNumber.ToString()
$newVersion = [string]::Join('.', $versionParts)
$versionWithoutBuildNumber = [string]::Join('.', $versionParts[0..2])
Set-Content "$dir\..\version.txt" $newVersion
$csprojContent = Get-Content $csprojPath
$newCsprojContent = $csprojContent -replace '(<FileVersion>)[0-9]+(\.[0-9]+){1,3}(</FileVersion>)', "`${1}$newVersion`$3"
$newCsprojContent = $newCsprojContent -replace '(<Version>)[0-9]+(\.[0-9]+){1,2}(</Version>)', "`${1}$versionWithoutBuildNumber`$3"
$newCsprojContent = $newCsprojContent -replace '(<AssemblyVersion>)[0-9]+(\.[0-9]+){1,3}(</AssemblyVersion>)', "`${1}$newVersion`$3"
Set-Content $csprojPath $newCsprojContent