/
GitVersion.psm1
38 lines (33 loc) · 1.1 KB
/
GitVersion.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
30
31
32
33
34
35
36
37
38
Set-StrictMode -Version latest
$ErrorActionPreference = "Stop"
[String]$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
Import-Module "$ScriptDir\Helper.psm1"
# -------------------------------------------------------------------------------------------------------------------------------------
# Tools
[string] $GitVersionToolPath = "$ScriptDir\bin\GitVersion\GitVersion.exe"
# -------------------------------------------------------------------------------------------------------------------------------------
function GitVersion
{
Param
(
[Parameter()][switch] $PauseOnError
)
Try
{
Write-Host -ForegroundColor "Green" "Determining version from the git history..."
Copy-Item "$ScriptDir\GitVersion.yml" -Destination "$ScriptDir\.."
$WorkingDirectory = Get-Location
Set-Location -Path "$ScriptDir\.."
EnvRunExec ( "$GitVersionToolPath", "/output", "buildserver" )
Set-Location -Path "$WorkingDirectory"
}
Catch [Exception]
{
# tell the caller it has all gone wrong
echo $_.Exception|format-list -force
if ($PauseOnError) {
Read-Host "Press ANY key..."
}
exit(-1)
}
}