-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
60 lines (53 loc) · 1.89 KB
/
Copy pathbuild.ps1
File metadata and controls
60 lines (53 loc) · 1.89 KB
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
param(
[ValidateSet("Restore", "Build", "Test", "TestE2E", "Mutate")]
[string] $Target = "Test"
)
$ErrorActionPreference = "Stop"
$SolutionFile = "RedcapApi.slnx"
$TestProject = "tests/RedcapApi.Tests/RedcapApi.Tests.csproj"
$StrykerProject = "src/RedcapApi"
$DotnetCliHome = Join-Path $PSScriptRoot ".dotnet-home"
$NuGetConfig = Join-Path $PSScriptRoot "NuGet.Config"
if (-not $env:DOTNET_CLI_HOME) {
New-Item -ItemType Directory -Path $DotnetCliHome -Force | Out-Null
$env:DOTNET_CLI_HOME = $DotnetCliHome
}
function Invoke-DotNet {
param(
[Parameter(Mandatory = $true)]
[string[]] $Arguments
)
& dotnet @Arguments
if ($LASTEXITCODE -ne 0) {
throw ("dotnet {0} failed with exit code {1}." -f ($Arguments -join " "), $LASTEXITCODE)
}
}
switch ($Target) {
"Restore" {
Invoke-DotNet @("restore", $SolutionFile, "--configfile", $NuGetConfig)
}
"Build" {
Invoke-DotNet @("restore", $SolutionFile, "--configfile", $NuGetConfig)
Invoke-DotNet @("build", $SolutionFile, "-c", "Release", "--no-restore")
}
"Test" {
Invoke-DotNet @("restore", $SolutionFile, "--configfile", $NuGetConfig)
Invoke-DotNet @("build", $SolutionFile, "-c", "Release", "--no-restore")
Invoke-DotNet @("test", $TestProject, "--filter", "Category!=E2E", "--verbosity", "minimal")
}
"TestE2E" {
Invoke-DotNet @("restore", $SolutionFile, "--configfile", $NuGetConfig)
Invoke-DotNet @("build", $SolutionFile, "-c", "Release", "--no-restore")
Invoke-DotNet @("test", $TestProject, "--verbosity", "minimal")
}
"Mutate" {
Invoke-DotNet @("tool", "restore", "--configfile", $NuGetConfig)
Push-Location $StrykerProject
try {
Invoke-DotNet @("stryker", "--config-file", "stryker-config.json")
}
finally {
Pop-Location
}
}
}