forked from danbarua/NEventSocket
-
Notifications
You must be signed in to change notification settings - Fork 11
/
BuildFunctions.psm1
29 lines (25 loc) · 885 Bytes
/
BuildFunctions.psm1
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
function Get-Version
{
param
(
[string]$assemblyInfoFilePath
)
Write-Host "path $assemblyInfoFilePath"
$pattern = '(?<=^\[assembly\: AssemblyVersion\(\")(?<versionString>\d+\.\d+\.\d+\.\d+)(?=\"\))'
$assmblyInfoContent = Get-Content $assemblyInfoFilePath
return $assmblyInfoContent | Select-String -Pattern $pattern | Select -expand Matches |% {$_.Groups['versionString'].Value}
}
function Update-Version
{
param
(
[string]$version,
[string]$assemblyInfoFilePath
)
$newVersion = 'AssemblyVersion("' + $version + '")';
$newFileVersion = 'AssemblyFileVersion("' + $version + '")';
$tmpFile = $assemblyInfoFilePath + ".tmp"
Get-Content $assemblyInfoFilePath |
%{$_ -replace 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $newFileVersion } | Out-File -Encoding UTF8 $tmpFile
Move-Item $tmpFile $assemblyInfoFilePath -force
}