-
Notifications
You must be signed in to change notification settings - Fork 1
/
UpdateVersionCs.ps1
30 lines (25 loc) · 970 Bytes
/
UpdateVersionCs.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
# SPDX-FileCopyrightText: Copyright (c) 2022 Dinh Ngoc Tu
# SPDX-License-Identifier: GPL-3.0-only
param([switch] $Force)
$vcsRev = git describe --tags --long --dirty --always
. "$PSScriptRoot\Version.ps1"
$productVersionText = "$($productVersion[0]).$($productVersion[1]).$($productVersion[2]).$($productVersion[3])"
$csFile = "$pwd\..\..\Properties\Version.cs"
$csOld = Get-Content -ErrorAction Ignore -Raw $csFile
$csNew = `
@"
using System.Reflection;
[assembly: AssemblyVersion("$productVersionText")]
[assembly: AssemblyFileVersion("$productVersionText")]
[assembly: AssemblyInformationalVersion("$productVersionText")]
namespace VietTypeConfig {
internal static class Version {
public const string ProductVersion = "$productVersionText";
public const string VcsRevision = "$vcsRev";
}
}
"@
if ($Force -or ($csOld -ne $csNew)) {
echo "Updating Version.cs"
[System.IO.File]::WriteAllText($csFile, [string]::Join("`n", $csNew))
}