-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
46 lines (37 loc) · 1.72 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
$ErrorActionPreference = "Stop"
Remove-Item "$PSScriptRoot\TestResults" -Recurse -Force -ErrorAction SilentlyContinue
if (Test-Path -Path "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe") {
$visualStudioPath = & "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath
if ($visualStudioPath) {
& "$visualStudioPath\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64
dotnet restore /t:slngen .\dirs.proj
}
}
dotnet restore dirs.proj
if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet restore failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
dotnet build dirs.proj --no-restore
if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet build failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
dotnet test dirs.proj --no-build --no-restore --logger "console" --blame --collect "XPlat Code coverage" --results-directory "$PSScriptRoot\TestResults\"
if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet test failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
dotnet publish dirs.proj --no-build --no-restore
if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet publish failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
if (-not (Test-Path -Path "$PSScriptRoot\tools\reportgenerator.exe")) {
dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools --ignore-failed-sources
if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet publish failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
}
.\tools\reportgenerator.exe "-reports:$PSScriptRoot\TestResults\*\coverage.cobertura.xml" "-targetdir:$PSScriptRoot\TestResults\coverage" "-reporttypes:HtmlInline_AzurePipelines;Cobertura"