/
InstrumentationTask.cs
58 lines (50 loc) · 1.34 KB
/
InstrumentationTask.cs
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
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using Coverlet.Core;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Coverlet.MSbuild.Tasks
{
public class InstrumentationTask : Task
{
private static Coverage _coverage;
private string _path;
private string _filter;
private string _excludeByFile;
internal static Coverage Coverage
{
get { return _coverage; }
}
[Required]
public string Path
{
get { return _path; }
set { _path = value; }
}
public string Filter
{
get { return _filter; }
set { _filter = value; }
}
public string ExcludeByFile
{
get { return _excludeByFile; }
set { _excludeByFile = value; }
}
public override bool Execute()
{
try
{
var excludes = _excludeByFile?.Split(',');
var filters = _filter?.Split(',');
_coverage = new Coverage(_path, Guid.NewGuid().ToString(), filters, excludes);
_coverage.PrepareModules();
}
catch (Exception ex)
{
Log.LogErrorFromException(ex);
return false;
}
return true;
}
}
}