forked from ASOS/SimpleEventStore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
52 lines (43 loc) · 1.66 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
Param(
[string]$Uri = "https://localhost:8081/",
[string]$AuthKey = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
[string]$ConsistencyLevel = "BoundedStaleness",
[string]$Configuration = "Release"
)
function Write-Stage([string]$name)
{
Write-Host $('=' * 30) -ForegroundColor Green
Write-Host $name -ForegroundColor Green
Write-Host $('=' * 30) -ForegroundColor Green
}
function Exec
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}
$outputDir = "../../output";
Push-Location src\SimpleEventStore
Write-Stage "Calculating Version"
dotnet tool restore
$gitVersion = dotnet gitversion | ConvertFrom-Json
$buildVersion = $gitVersion.LegacySemVer
Write-Host "Build version set to '$buildVersion'"
Write-Stage "Building solution"
Exec { dotnet build -c $Configuration -p:BuildVersion=$buildVersion }
Write-Stage "Running tests"
$env:Uri = $Uri
$env:AuthKey = $AuthKey
$env:ConsistencyLevel = $ConsistencyLevel
Exec { dotnet test SimpleEventStore.Tests -c $Configuration --no-build --logger trx }
Exec { dotnet test SimpleEventStore.CosmosDb.Tests -c $Configuration --no-build --logger trx }
Write-Stage "Creating nuget packages"
Exec { dotnet pack SimpleEventStore -c $Configuration -o $outputDir -p:BuildVersion=$buildVersion --no-build }
Exec { dotnet pack SimpleEventStore.CosmosDb -c $Configuration -o $outputDir -p:BuildVersion=$buildVersion --no-build }
Pop-Location