forked from rscustom/rocksmith-custom-song-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatchAssemblyVersion.ps1
27 lines (19 loc) · 1.07 KB
/
PatchAssemblyVersion.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
param([string]$Assembly_File)
$content = [IO.File]::ReadAllText($Assembly_File)
$regexAIV = new-object System.Text.RegularExpressions.Regex ('(AssemblyInformationalVersion(Attribute)?\s*\(\s*\")(.*)(\"\s*\))',
[System.Text.RegularExpressions.RegexOptions]::MultiLine)
$regexAV = new-object System.Text.RegularExpressions.Regex ('(AssemblyVersion(Attribute)?\s*\(\s*\")(.*)(\"\s*\))',
[System.Text.RegularExpressions.RegexOptions]::MultiLine)
# new version
$env:GIT_HASH = $env:APPVEYOR_REPO_COMMIT.Substring(0, 8)
$Assembly_Informational_Version = "$env:GIT_HASH"
# edit the AssemblyVersion here
# will be applied to all AssemblyInfo.cs files ...
$Assembly_Version = "2.7.1.0"
Write-Host "- Patching: $Assembly_File"
Write-Host "- AssemblyVersion: $Assembly_Version"
Write-Host "- AssemblyInformationVersion: $env:GIT_HASH"
# update assembly info
$content = $regexAIV.Replace($content, '${1}' + $Assembly_Informational_Version + '${4}')
$content = $regexAV.Replace($content, '${1}' + $Assembly_Version + '${4}')
[IO.File]::WriteAllText($Assembly_File, $content)