forked from ixmilia/converters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-and-test.ps1
executable file
·57 lines (45 loc) · 1.5 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/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 {
$runTests = -Not $noTest;
# build dxf submodule
$shellExt = if ($IsWindows) { "cmd" } else { "sh" }
Push-Location "$PSScriptRoot\src\IxMilia.Dxf"
& "./build-and-test.${shellExt}" --configuration $configuration --notest || Fail "Error building DXF submodule"
Pop-Location
# build dwg submodule
Push-Location "$PSScriptRoot\src\IxMilia.Dwg"
. .\build-and-test.ps1 -configuration $configuration -noTest
Pop-Location
dotnet restore || Fail "Error restoring packages"
dotnet build --configuration $configuration || Fail "Error building"
if ($runTests) {
dotnet test --no-restore --no-build --configuration $configuration || Fail "Error running tests"
}
dotnet pack --no-restore --no-build --configuration $configuration || Fail "Error building packages"
$package = Single "$PSScriptRoot\artifacts\packages\$configuration\*.nupkg"
Write-Host "Package generated at '$package'"
}
catch {
Write-Host $_
Write-Host $_.Exception
Write-Host $_.ScriptStackTrace
exit 1
}