-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathversionnumber.ps1
62 lines (55 loc) · 2.91 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
51
52
53
54
55
56
57
58
59
60
61
62
[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"
$local:BuildNumber = ($BuildId % 65535) # max value for version part on Windows is 65534
Write-Host "BuildNumber = $($local:BuildNumber)"
$local:PackageCodeMarker = "255.255.65534"
$local:AssemblyCodeMarker = "255.255.65534.65534"
$local:AssemblyVersion = "${SemanticVersion}.$($local:BuildNumber)"
$local:PwShellVersion = "${SemanticVersion}.$($BuildId)"
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 "PwShellVersion = $($local:PwShellVersion)"
Write-Host "Replacing version information in SafeguardDevOpsService assembly info"
$local:ProjectFile = (Join-Path $PSScriptRoot "SafeguardDevOpsService\Properties\AssemblyInfo.cs")
(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-Output "*****"
Get-Content $local:ProjectFile
Write-Output "*****"
Write-Host "Replacing version information in DevOpsPluginCommon project file"
$local:ProjectFile = (Join-Path $PSScriptRoot "DevOpsPluginCommon\DevOpsPluginCommon.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-Output "*****"
Get-Content $local:ProjectFile
Write-Output "*****"
Write-Host "Replacing version information in DevOpsAddonCommon project file"
$local:ProjectFile = (Join-Path $PSScriptRoot "DevOpsAddonCommon\DevOpsAddonCommon.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-Output "*****"
Get-Content $local:ProjectFile
Write-Output "*****"
Write-Output "##vso[task.setvariable variable=VersionString;]$($local:AssemblyVersion)"
Write-Output "##vso[task.setvariable variable=PwShellVersionString;]$($local:PwShellVersion)"