-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_version.ps1
56 lines (42 loc) · 1.58 KB
/
set_version.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
# PowerShell Cinegy Build Script
# COPYRIGHT Cinegy 2020-2022
param([string]$BuildCounter=0,[string]$SourceRevisionValue="FFFFFF",[string]$OverrideMinorVersion="")
$majorVer = 2
$minorVer = 0
#minor version may be overridden (e.g. on integration builds)
if($OverrideMinorVersion)
{
$minorVer = $OverrideMinorVersion
}
#calculte a UInt16 from the commit hash to use as 4th version flag
$shortRev = $SourceRevisionValue.Substring(0,4)
$sourceAsDecimal = [System.Convert]::ToUInt16($shortRev, 16) -1
$softwareVersion = "$majorVer.$minorVer.$BuildCounter.$sourceAsDecimal"
#set global variable to version number
$env:SoftwareVersion = $softwareVersion
Get-ChildItem -Path *.csproj -Recurse | ForEach-Object {
$fileName = $_
Write-Host "Processing metadata changes for file: $fileName"
[xml]$projectXml = Get-Content -Path $fileName
$nodes = $projectXml.SelectNodes("/Project/PropertyGroup/Copyright")
foreach($node in $nodes) {
$node.'#text' = "$([char]0xA9)$((Get-Date).year) Cinegy. All rights reserved."
}
$nodes = $projectXml.SelectNodes("/Project/PropertyGroup/Description")
foreach($node in $nodes) {
$node.'#text' = "$($node.'#text')"
}
$nodes = $projectXml.SelectNodes("/Project/PropertyGroup/Version")
foreach($node in $nodes) {
$node.'#text' = $SoftwareVersion
}
$nodes = $projectXml.SelectNodes("/Project/PropertyGroup/AssemblyVersion")
foreach($node in $nodes) {
$node.'#text' = $SoftwareVersion
}
$nodes = $projectXml.SelectNodes("/Project/PropertyGroup/FileVersion")
foreach($node in $nodes) {
$node.'#text' = $SoftwareVersion
}
$projectXml.Save($fileName)
}