Skip to content

Commit a228498

Browse files
committed
fix CoverletOutput parameter
1 parent f8004bb commit a228498

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

Documentation/MSBuildIntegration.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ To specify a directory where all results will be written to (especially if using
5050
dotnet test /p:CollectCoverage=true /p:CoverletOutput='./results/'
5151
```
5252

53+
_Note: escape characters might produce some unexpected results._
54+
55+
|status| msbuild parameter |
56+
|---|---|
57+
|:heavy_check_mark:|`/p:CoverletOutput="C:/GitHub/coverlet/artifacts/Reports/coverlet.core/"`|
58+
|:heavy_check_mark:|`/p:CoverletOutput="C:\\GitHub\\coverlet\\artifacts\\Reports\\coverlet.core\\"`|
59+
|:heavy_check_mark:|`/p:CoverletOutput="C:\GitHub\coverlet\artifacts\Reports\coverlet.core\\"`|
60+
|:x:|`/p:CoverletOutput="C:\GitHub\coverlet\artifacts\Reports\coverlet.core\"`|
61+
5362
The Coverlet MSBuild task sets the `CoverletReport` MSBuild item so that you can easily use the produced coverage reports. For example, using [ReportGenerator](https://github.com/danielpalme/ReportGenerator#usage--command-line-parameters) to generate an html coverage report.
5463

5564
```xml

eng/publish-coverage-results.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ steps:
1919
script: |
2020
dotnet tool restore --add-source https://api.nuget.org/v3/index.json
2121
dotnet tool list
22-
dotnet reportgenerator -reports:"${{parameters.reports}}" -targetdir:"$(Build.SourcesDirectory)\artifacts\CoverageReport" -reporttypes:"Html;HtmlInline_AzurePipelines_Dark;Cobertura" -assemblyfilters:"${{parameters.assemblyfilters}}" -classfilters:"${{parameters.classfilters}}" -verbosity:Verbose --minimumCoverageThresholds:lineCoverage=${{parameters.minimumLineCoverage}}
22+
dotnet reportgenerator -reports:"${{parameters.reports}}" -targetdir:"$(Build.SourcesDirectory)\artifacts\CoverageReport" -reporttypes:"HtmlInline_AzurePipelines_Dark;Cobertura" -assemblyfilters:"${{parameters.assemblyfilters}}" -classfilters:"${{parameters.classfilters}}" -verbosity:Verbose --minimumCoverageThresholds:lineCoverage=${{parameters.minimumLineCoverage}}
2323
2424
- publish: '$(Build.SourcesDirectory)/artifacts/CoverageReport'
2525
displayName: 'Publish CoverageReport Artifact'

src/coverlet.core/coverlet.core.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
<PackageReference Include="Mono.Cecil" />
1515
<PackageReference Include="NuGet.Versioning" />
1616
<PackageReference Include="System.Text.Json" VersionOverride="8.0.1"/>
17-
<!--<PackageReference Include="PolySharp" >
18-
<PrivateAssets>all</PrivateAssets>
19-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
20-
</PackageReference>-->
21-
2217
</ItemGroup>
2318

2419
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">

src/coverlet.msbuild.tasks/ReportWriter.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Coverlet.MSbuild.Tasks
1010
internal class ReportWriter
1111
{
1212
private readonly string _coverletMultiTargetFrameworksCurrentTFM;
13-
private readonly string _directory;
13+
private string _directory;
1414
private readonly string _output;
1515
private readonly IReporter _reporter;
1616
private readonly IFileSystem _fileSystem;
@@ -30,9 +30,10 @@ public string WriteReport()
3030

3131
if (filename == string.Empty)
3232
{
33-
// empty filename for instance only directory is passed to CoverletOutput c:\reportpath
34-
// c:\reportpath\coverage.reportedextension
33+
// empty filename for instance only directory is passed to CoverletOutput 'c:/reportpath/'
34+
// note: use always '/' and not backslash => 'c:\reportpath\coverage.cobertura.xml'
3535
filename = $"coverage.{_coverletMultiTargetFrameworksCurrentTFM}{separatorPoint}{_reporter.Extension}";
36+
_directory = Path.GetFullPath(_output);
3637
}
3738
else if (Path.HasExtension(filename))
3839
{
@@ -49,6 +50,7 @@ public string WriteReport()
4950

5051
string report = Path.Combine(_directory, filename);
5152
_fileSystem.WriteAllText(report, _reporter.Report(_result, _sourceRootTranslator));
53+
5254
return report;
5355
}
5456
}

test/coverlet.tests.utils/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88
[assembly: InternalsVisibleTo("coverlet.core.tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100757cf9291d78a82e5bb58a827a3c46c2f959318327ad30d1b52e918321ffbd847fb21565b8576d2a3a24562a93e86c77a298b564a0f1b98f63d7a1441a3a8bcc206da3ed09d5dacc76e122a109a9d3ac608e21a054d667a2bae98510a1f0f653c0e6f58f42b4b3934f6012f5ec4a09b3dfd3e14d437ede1424bdb722aead64ad")]
99
[assembly: InternalsVisibleTo("coverlet.integration.tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010001d24efbe9cbc2dc49b7a3d2ae34ca37cfb69b4f450acd768a22ce5cd021c8a38ae7dc68b2809a1ac606ad531b578f192a5690b2986990cbda4dd84ec65a3a4c1c36f6d7bb18f08592b93091535eaee2f0c8e48763ed7f190db2008e1f9e0facd5c0df5aaab74febd3430e09a428a72e5e6b88357f92d78e47512d46ebdc3cbb")]
1010

11-

0 commit comments

Comments
 (0)