Skip to content

Commit 7de1b63

Browse files
committed
Run a build before coverage analysis
* Ensures the outputs are up-to-date before proceeding * Ensures NuGet packages are restored before proceeding
1 parent 1a1c6df commit 7de1b63

2 files changed

Lines changed: 11 additions & 24 deletions

File tree

build/build.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ If (-not (Test-Path $nuget)) {
4747

4848
# build the main project
4949
$msbuild = "${env:ProgramFiles(x86)}\MSBuild\$VisualStudioVersion\Bin\MSBuild.exe"
50+
If (-not (Test-Path $msbuild)) {
51+
$host.UI.WriteErrorLine("Couldn't find MSBuild.exe")
52+
exit 1
53+
}
5054

5155
# Attempt to restore packages up to 3 times, to improve resiliency to connection timeouts and access denied errors.
5256
$maxAttempts = 3

build/opencover-report.ps1

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,17 @@
1+
# Run a build to ensure everything is up-to-date
2+
.\build.ps1 -Debug -Incremental
3+
If (-not $?) {
4+
$host.UI.WriteErrorLine('Build failed; coverage analysis aborted.')
5+
Exit $LASTEXITCODE
6+
}
7+
18
$packages_folder = '..\packages'
29
$opencover_console = "$packages_folder\OpenCover.4.6.247-rc\tools\OpenCover.Console.exe"
310
$xunit_runner_console = "$packages_folder\xunit.runner.console.2.1.0\tools\xunit.console.x86.exe"
411
$report_generator = "$packages_folder\ReportGenerator.2.3.5.0\tools\ReportGenerator.exe"
512
$report_folder = '.\OpenCover.Reports'
613
$target_dll = '..\StyleCop.Analyzers\StyleCop.Analyzers.Test\bin\Debug\StyleCop.Analyzers.Test.dll'
714

8-
If (-not (Test-Path $target_dll)) {
9-
$host.UI.WriteErrorLine('target dll not found (build target?)')
10-
$host.UI.WriteErrorLine("$target_dll")
11-
Exit 1
12-
}
13-
14-
If (-not (Test-Path $opencover_console)) {
15-
$host.UI.WriteErrorLine('OpenCover Console not found (nuget restore?)')
16-
$host.UI.WriteErrorLine("$opencover_console")
17-
Exit 1
18-
}
19-
20-
If (-not (Test-Path $xunit_runner_console)) {
21-
$host.UI.WriteErrorLine('OpenCover Console not found (nuget restore?)')
22-
$host.UI.WriteErrorLine("$xunit_runner_console")
23-
Exit 1
24-
}
25-
26-
If (-not (Test-Path $report_generator)) {
27-
$host.UI.WriteErrorLine('Report Generator not found (nuget restore?)')
28-
$host.UI.WriteErrorLine("$report_generator")
29-
Exit 1
30-
}
31-
3215
If (Test-Path $report_folder) {
3316
Remove-Item -Recurse -Force $report_folder
3417
}

0 commit comments

Comments
 (0)