forked from StackExchange/StackExchange.Redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
74 lines (62 loc) · 2.43 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
70
71
72
73
74
[CmdletBinding(PositionalBinding=$false)]
param(
[bool] $CreatePackages,
[switch] $StartServers,
[bool] $RunTests = $true,
[string] $PullRequestNumber
)
Write-Host "Run Parameters:" -ForegroundColor Cyan
Write-Host " CreatePackages: $CreatePackages"
Write-Host " RunTests: $RunTests"
Write-Host " dotnet --version:" (dotnet --version)
$packageOutputFolder = "$PSScriptRoot\.nupkgs"
$projectsToBuild =
'StackExchange.Redis',
'NRediSearch'
$testsToRun =
'StackExchange.Redis.Tests'
if ($PullRequestNumber) {
Write-Host "Building for a pull request (#$PullRequestNumber), skipping packaging." -ForegroundColor Yellow
$CreatePackages = $false
}
Write-Host "Building projects..." -ForegroundColor "Magenta"
foreach ($project in $projectsToBuild + $testsToRun) {
Write-Host "Building $project (dotnet restore/build)..." -ForegroundColor "Magenta"
dotnet restore ".\src\$project\$project.csproj" /p:CI=true
dotnet build ".\src\$project\$project.csproj" -c Release /p:CI=true
Write-Host ""
}
Write-Host "Done building." -ForegroundColor "Green"
if ($RunTests) {
if ($StartServers) {
Write-Host "Starting all servers for testing: $project (all frameworks)" -ForegroundColor "Magenta"
& .\RedisConfigs\start-all.cmd
Write-Host "Servers Started." -ForegroundColor "Green"
}
foreach ($project in $testsToRun) {
Write-Host "Running tests: $project (all frameworks)" -ForegroundColor "Magenta"
#Push-Location ".\tests\$project"
Push-Location ".\tests\$project"
dotnet test -c Release
if ($LastExitCode -ne 0) {
Write-Host "Error with tests, aborting build." -Foreground "Red"
Pop-Location
Exit 1
}
Write-Host "Tests passed!" -ForegroundColor "Green"
Pop-Location
}
}
if ($CreatePackages) {
mkdir -Force $packageOutputFolder | Out-Null
Write-Host "Clearing existing $packageOutputFolder..." -NoNewline
Get-ChildItem $packageOutputFolder | Remove-Item
Write-Host "done." -ForegroundColor "Green"
Write-Host "Building all packages" -ForegroundColor "Green"
foreach ($project in $projectsToBuild) {
Write-Host "Packing $project (dotnet pack)..." -ForegroundColor "Magenta"
dotnet pack ".\src\$project\$project.csproj" --no-build -c Release /p:PackageOutputPath=$packageOutputFolder /p:NoPackageAnalysis=true /p:CI=true
Write-Host ""
}
}
Write-Host "Done."