-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathversion.ps1
More file actions
24 lines (17 loc) · 844 Bytes
/
version.ps1
File metadata and controls
24 lines (17 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$buildSalt = $ENV:BUILD_NUMBER
$branchName = $ENV:BRANCH_NAME
# Writing build salt and branch name
$gitSimpleVersion = git describe --tags --abbrev=0 2>$null
if (!$gitSimpleVersion) {
$gitSimpleVersion = "0.0.1" # Default version
}
$simpleVersionStandard = echo $gitSimpleVersion | Select-String -Pattern "([0-9]+)\.([0-9]+)\.([0-9]+)" | % {$_.Matches} | %{$_.Groups[1].Value+"."+$_.Groups[2].Value+"."+$_.Groups[3].Value}
$dotNetVersion = "$simpleVersionStandard.$buildSalt"
$infoVersion = -join(("$gitSimpleVersion" -replace "([0-9]+)\.([0-9]+)\.([0-9]+)","$dotNetVersion"), "-", "$branchName")
$fileContent = @"
using System.Reflection;
[assembly: AssemblyVersion("$dotNetVersion")]
[assembly: AssemblyInformationalVersion("$infoVersion")]
"@
echo $fileContent | Set-Content "$PSScriptRoot/AssemblyVersion.cs"
echo "$infoVersion"