forked from OneIdentity/SafeguardDotNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
versionnumber.ps1
50 lines (42 loc) · 2.2 KB
/
versionnumber.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true, Position=0)]
[string]$SourceDir,
[Parameter(Mandatory=$true, Position=1)]
[string]$SemanticVersion,
[Parameter(Mandatory=$true, Position=2)]
[string]$BuildId,
[Parameter(Mandatory=$true, Position=3)]
[bool]$IsPrerelease
)
Write-Host "SemanticVersion = $SemanticVersion"
Write-Host "BuildId = $BuildId"
# Build number must be between 0 - 65534
$local:BuildNumber = $BuildId % 65534
Write-Host "BuildNumber = $($local:BuildNumber)"
$local:PackageCodeMarker = "9999.9999.9999"
$local:AssemblyCodeMarker = "9999.9999.9999.9999"
$local:AssemblyVersion = "${SemanticVersion}.$($local:BuildNumber)"
if ($IsPrerelease)
{
$local:PackageVersion = "${SemanticVersion}-dev-$($local:BuildNumber)"
}
else
{
$local:PackageVersion = $SemanticVersion
}
Write-Host "PackageCodeMarker = $($local:PackageCodeMarker)"
Write-Host "AssemblyCodeMarker = $($local:AssemblyCodeMarker)"
Write-Host "PackageVersion = $($local:PackageVersion)"
Write-Host "AssemblyVersion = $($local:AssemblyVersion)"
Write-Host "Replacing markers in SafeguardDotNet"
$local:ProjectFile = (Join-Path $PSScriptRoot "SafeguardDotNet\SafeguardDotNet.csproj")
(Get-Content $local:ProjectFile -Raw).replace($local:AssemblyCodeMarker, $local:AssemblyVersion) | Set-Content -Encoding UTF8 $local:ProjectFile
(Get-Content $local:ProjectFile -Raw).replace($local:PackageCodeMarker, $local:PackageVersion) | Set-Content -Encoding UTF8 $local:ProjectFile
Write-Host "Replacing markers in SafeguardDotNet.GuiLogin"
$local:GuiAssemblyInfoFile = (Join-Path $PSScriptRoot "SafeguardDotNet.GuiLogin\Properties\AssemblyInfo.cs")
$local:GuiNuspec = (Join-Path $PSScriptRoot "SafeguardDotNet.GuiLogin\SafeguardDotNet.GuiLogin.nuspec")
(Get-Content $local:GuiAssemblyInfoFile -Raw).replace($local:AssemblyCodeMarker, $local:AssemblyVersion) | Set-Content -Encoding UTF8 $local:GuiAssemblyInfoFile
(Get-Content $local:GuiNuspec -Raw).replace($local:PackageCodeMarker, $local:PackageVersion) | Set-Content -Encoding UTF8 $local:GuiNuspec
Write-Output "##vso[task.setvariable variable=AssemblyVersion;]$($local:AssemblyVersion)"
Write-Output "##vso[task.setvariable variable=PackageVersion;]$($local:PackageVersion)"