Skip to content

Commit cb56509

Browse files
committed
update streamline options to specify coverage output file
1 parent dcf41fe commit cb56509

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/coverlet.msbuild.tasks/CoverageResultTask.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ namespace Coverlet.MSbuild.Tasks
1212
{
1313
public class CoverageResultTask : Task
1414
{
15-
private string _filename;
15+
private string _output;
1616
private string _format;
1717
private int _threshold;
1818
private string _thresholdType;
1919

2020
[Required]
2121
public string Output
2222
{
23-
get { return _filename; }
24-
set { _filename = value; }
23+
get { return _output; }
24+
set { _output = value; }
2525
}
2626

2727
[Required]
@@ -54,11 +54,9 @@ public override bool Execute()
5454
var coverage = InstrumentationTask.Coverage;
5555
var result = coverage.GetCoverageResult();
5656

57-
var directory = Path.GetDirectoryName(_filename);
57+
var directory = Path.GetDirectoryName(_output);
5858
if (!Directory.Exists(directory))
59-
{
6059
Directory.CreateDirectory(directory);
61-
}
6260

6361
var formats = _format.Split(',');
6462
foreach (var format in formats)
@@ -67,7 +65,10 @@ public override bool Execute()
6765
if (reporter == null)
6866
throw new Exception($"Specified output format '{format}' is not supported");
6967

70-
var report = _filename + "." + reporter.Extension;
68+
var filename = Path.GetFileName(_output);
69+
filename = (filename == string.Empty) ? $"coverage.{reporter.Extension}" : filename;
70+
71+
var report = Path.Combine(directory, filename);
7172
Console.WriteLine($" Generating report '{report}'");
7273
File.WriteAllText(report, reporter.Report(result));
7374
}
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2-
32
<PropertyGroup>
3+
<CollectCoverage Condition="$(CollectCoverage) == ''">false</CollectCoverage>
44
<CoverletOutputFormat Condition="$(CoverletOutputFormat) == ''">json</CoverletOutputFormat>
5-
<CoverletOutputDirectory Condition="$(CoverletOutputDirectory) == ''">$(MSBuildProjectDirectory)</CoverletOutputDirectory>
6-
<CoverletOutputName Condition=" '$(CoverletOutputName)' == '' ">coverage</CoverletOutputName>
7-
<CoverletOutput>$([MSBuild]::EnsureTrailingSlash('$(CoverletOutputDirectory)'))$(CoverletOutputName)</CoverletOutput>
5+
<CoverletOutput Condition="$(CoverletOutput) == ''">$([MSBuild]::EnsureTrailingSlash('$(MSBuildProjectDirectory)'))</CoverletOutput>
86
<Exclude Condition="$(Exclude) == ''"></Exclude>
97
<ExcludeByFile Condition="$(ExcludeByFile) == ''"></ExcludeByFile>
108
<Threshold Condition="$(Threshold) == ''">0</Threshold>
119
<ThresholdType Condition="$(ThresholdType) == ''">line,branch,method</ThresholdType>
12-
<CollectCoverage Condition="$(CollectCoverage) == ''">false</CollectCoverage>
1310
</PropertyGroup>
14-
1511
</Project>

0 commit comments

Comments
 (0)