-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.ps1
61 lines (46 loc) · 1.58 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
function Build-Project
{
param([string] $DirectoryName)
Push-Location $DirectoryName
& dotnet build -c Release
if($LASTEXITCODE -ne 0) { exit 1 }
Pop-Location
}
function Pack-Project
{
param([string] $DirectoryName)
Push-Location $DirectoryName
& dotnet pack -c Release -o ..\.\artifacts
if($LASTEXITCODE -ne 0) { exit 1 }
Pop-Location
}
function Update-BuildVersion
{
param([string] $FileName)
$revision = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "0.0.1" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$csprojContent = Get-Content $FileName
$csprojContent | % { $_.Replace("0.0.1", $revision) } | Set-Content $FileName
Write-Host "Set version of $FileName to $revision"
}
function Test-Project
{
param([string] $DirectoryName)
Push-Location $DirectoryName
& dotnet test -c Release
if($LASTEXITCODE -ne 0) { exit 2 }
Pop-Location
}
Push-Location $PSScriptRoot
# Clean
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
# Modify version in csproj files
Get-ChildItem -Path .\src -Filter *.csproj -Recurse | ForEach-Object { Update-BuildVersion $_.FullName }
# Package restore
& dotnet restore
# Build/package
Get-ChildItem -Path .\src -Filter *.csproj -Recurse | ForEach-Object { Pack-Project $_.DirectoryName }
# Build examples to ensure they at least build
Get-ChildItem -Path .\Example -Filter *.csproj -Recurse | ForEach-Object { Build-Project $_.DirectoryName }
# Test
Get-ChildItem -Path .\test -Filter *.csproj -Recurse | ForEach-Object { Test-Project $_.DirectoryName }
Pop-Location