/
build.ps1
69 lines (59 loc) · 2.03 KB
/
build.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
58
59
60
61
62
63
64
65
66
67
68
69
function Print-Header($title) {
Write-Host ""
Write-Host "$title" -f Cyan
Write-Host "$("-" * 80)" -f Yellow
}
$ErrorActionPreference = "Stop"
# -----------------------------------------------------------------------------
#
# Detect build version
#
# -----------------------------------------------------------------------------
Print-Header "Detecting version number"
if($env:APPVEYOR) {
$VERSION = $env:APPVEYOR_BUILD_VERSION
} else {
Write-Host "Build is not running on AppVeyor, will use default version number v1.0.0"
$VERSION = "1.0.0"
}
Write-Host "Version number: " -n
Write-Host "$VERSION" -f yellow
# -----------------------------------------------------------------------------
#
# Restore nuget package dependencies
#
# -----------------------------------------------------------------------------
Print-Header "Restoring dependencies"
& dotnet restore /nologo -v q
if($LASTEXITCODE -ne 0) {
Write-Host "dotnet restore failed with $LASTEXITCODE"
exit $LASTEXITCODE
}
# -----------------------------------------------------------------------------
#
# Compile projects
#
# -----------------------------------------------------------------------------
Print-Header "Compiling"
& dotnet build /nologo -v q -c Release /p:Version=$VERSION
if($LASTEXITCODE -ne 0) {
Write-Host "dotnet build failed with $LASTEXITCODE"
exit $LASTEXITCODE
}
# -----------------------------------------------------------------------------
#
# Create nuget packages
#
# -----------------------------------------------------------------------------
Print-Header "Packaging artifacts"
$ARTIFACTS = Join-Path (Resolve-Path ".") "artifacts"
if(-not (Test-Path $ARTIFACTS)) {
New-Item -Path $ARTIFACTS -ItemType Directory | Out-Null
}
Get-ChildItem $ARTIFACTS | Remove-Item -Recurse -Force
& dotnet pack /nologo -v q -c Release /p:Version=$VERSION --include-symbols --include-source --output $ARTIFACTS
if($LASTEXITCODE -ne 0) {
Write-Host "dotnet pack failed with $LASTEXITCODE"
exit $LASTEXITCODE
}
Write-Host "Completed" -f Green