-
Notifications
You must be signed in to change notification settings - Fork 7
/
build-and-test.ps1
executable file
·43 lines (36 loc) · 1.08 KB
/
build-and-test.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
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/pwsh
[CmdletBinding(PositionalBinding = $false)]
param (
[string]$configuration = "Debug",
[switch]$noTest
)
Set-StrictMode -version 2.0
$ErrorActionPreference = "Stop"
function Fail([string]$message) {
throw $message
}
function Single([string]$pattern) {
$items = @(Get-Item $pattern)
if ($items.Length -ne 1) {
$itemsList = $items -Join "`n"
Fail "Expected single item, found`n$itemsList`n"
}
return $items[0]
}
try {
. "$PSScriptRoot/generate-code.ps1"
dotnet restore || Fail "Error restoring."
dotnet build --configuration $configuration || Fail "Error building."
if (-Not $noTest) {
dotnet test --no-restore --no-build --configuration $configuration || Fail "Error running tests."
}
dotnet pack --no-restore --no-build --configuration $configuration || "Error creating package."
$package = Single "$PSScriptRoot/artifacts/packages/$configuration/*.nupkg"
Write-Host "Package generated at '$package'"
}
catch {
Write-Host $_
Write-Host $_.Exception
Write-Host $_.ScriptStackTrace
exit 1
}