Skip to content

Commit 96966f5

Browse files
committed
Merge pull request #2020 from sharwell/fix-2011
Convert opencover-report.bat to PowerShell
2 parents 7fb205e + 81b3391 commit 96966f5

4 files changed

Lines changed: 54 additions & 48 deletions

File tree

StyleCopAnalyzers.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{A0840AD0
2727
build\build.ps1 = build\build.ps1
2828
build\check-key.ps1 = build\check-key.ps1
2929
build\keys.ps1 = build\keys.ps1
30+
build\opencover-report.ps1 = build\opencover-report.ps1
3031
build\push.ps1 = build\push.ps1
3132
build\version.ps1 = build\version.ps1
3233
EndProjectSection

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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
param (
2+
[switch]$Debug
3+
)
4+
5+
# Run a build to ensure everything is up-to-date
6+
If ($Debug) {
7+
.\build.ps1 -Debug -Incremental
8+
} Else {
9+
.\build.ps1 -Incremental
10+
}
11+
12+
If (-not $?) {
13+
$host.UI.WriteErrorLine('Build failed; coverage analysis aborted.')
14+
Exit $LASTEXITCODE
15+
}
16+
17+
If ($Debug) {
18+
$Configuration = 'Debug'
19+
} Else {
20+
$Configuration = 'Release'
21+
}
22+
23+
$packages_folder = '..\packages'
24+
$opencover_console = "$packages_folder\OpenCover.4.6.247-rc\tools\OpenCover.Console.exe"
25+
$xunit_runner_console = "$packages_folder\xunit.runner.console.2.1.0\tools\xunit.console.x86.exe"
26+
$report_generator = "$packages_folder\ReportGenerator.2.3.5.0\tools\ReportGenerator.exe"
27+
$report_folder = '.\OpenCover.Reports'
28+
$target_dll = "..\StyleCop.Analyzers\StyleCop.Analyzers.Test\bin\$Configuration\StyleCop.Analyzers.Test.dll"
29+
30+
If (Test-Path $report_folder) {
31+
Remove-Item -Recurse -Force $report_folder
32+
}
33+
34+
mkdir $report_folder | Out-Null
35+
36+
&$opencover_console `
37+
-register:user `
38+
-threshold:1 `
39+
-returntargetcode `
40+
-hideskipped:All `
41+
-filter:"+[StyleCop*]*" `
42+
-excludebyattribute:*.ExcludeFromCodeCoverage* `
43+
-output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" `
44+
-target:"$xunit_runner_console" `
45+
-targetargs:"$target_dll -noshadow"
46+
47+
&$report_generator -targetdir:$report_folder -reports:$report_folder\OpenCover.*.xml
48+
49+
$host.UI.WriteLine("Open $report_folder\index.htm to see code coverage results.")

opencover-report.bat

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)