-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild.ps1
More file actions
75 lines (61 loc) · 1.99 KB
/
build.ps1
File metadata and controls
75 lines (61 loc) · 1.99 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Function Info($msg) {
Write-Host -ForegroundColor DarkGreen "`nINFO: $msg`n"
}
Function Error($msg) {
Write-Host `n`n
Write-Error $msg
exit 1
}
Function CheckReturnCodeOfPreviousCommand($msg) {
if(-Not $?) {
Error "${msg}. Error code: $LastExitCode"
}
}
Function GetVersion() {
$gitCommand = Get-Command -Name git
try { $tag = & $gitCommand describe --exact-match --tags HEAD 2> $null } catch { }
if(-Not $?) {
Info "The commit is not tagged. Use 'v0.0-dev' as a version instead"
$tag = "v0.0-dev"
}
$commitHash = & $gitCommand rev-parse --short HEAD
CheckReturnCodeOfPreviousCommand "Failed to get git commit hash"
return "$($tag.Substring(1))-$commitHash"
}
Function GetInstallerVersion($version) {
return $version.Split("-")[0];
}
Function RemoveFileIfExists($fileName) {
Info "Remove '$fileName'"
Remove-Item $fileName -Force -Recurse -ErrorAction SilentlyContinue
}
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
$root = Resolve-Path "$PSScriptRoot"
$buildDir = "$root/build"
$publishDir = "$buildDir/Release/Installer"
$version = GetVersion
$installerVersion = GetInstallerVersion $version
Info "Version: '$version'. InstallerVersion: '$installerVersion'"
Info "Build project"
dotnet build `
--nologo `
--configuration Release `
-verbosity:minimal `
/property:DebugType=None `
/property:Version=$version `
/property:InstallerVersion=$installerVersion `
"$root/ShowWhatProcessLocksFile.sln"
CheckReturnCodeOfPreviousCommand "build failed"
Info "Run tests"
dotnet test `
--nologo `
--no-build `
--configuration Release `
-verbosity:minimal `
--logger:"console;verbosity=normal" `
$root/ShowWhatProcessLocksFile.sln
CheckReturnCodeOfPreviousCommand "tests failed"
Info "Create zip archive from msi installer"
Compress-Archive -Force -Path "$publishDir/ShowWhatProcessLocksFile.msi" -DestinationPath "$publishDir/ShowWhatProcessLocksFile.msi.zip"