-
Notifications
You must be signed in to change notification settings - Fork 386
/
coverlet.msbuild.targets
88 lines (80 loc) · 4.53 KB
/
coverlet.msbuild.targets
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Coverlet.MSbuild.Tasks.InstrumentationTask" AssemblyFile="$(CoverletToolsPath)coverlet.msbuild.tasks.dll"/>
<UsingTask TaskName="Coverlet.MSbuild.Tasks.CoverageResultTask" AssemblyFile="$(CoverletToolsPath)coverlet.msbuild.tasks.dll"/>
<PropertyGroup>
<_CoverletSdkNETCoreSdkVersion>$(NETCoreSdkVersion)</_CoverletSdkNETCoreSdkVersion>
<_CoverletSdkNETCoreSdkVersion Condition="$(_CoverletSdkNETCoreSdkVersion.Contains('-'))">$(_CoverletSdkNETCoreSdkVersion.Split('-')[0])</_CoverletSdkNETCoreSdkVersion>
<_CoverletSdkMinVersionWithDependencyTarget>6.0.100</_CoverletSdkMinVersionWithDependencyTarget>
<_CoverletSourceRootTargetName>CoverletGetPathMap</_CoverletSourceRootTargetName>
<_CoverletSourceRootTargetName Condition="'$([System.Version]::Parse($(_CoverletSdkNETCoreSdkVersion)).CompareTo($([System.Version]::Parse($(_CoverletSdkMinVersionWithDependencyTarget)))))' >= '0' ">InitializeSourceRootMappedPaths</_CoverletSourceRootTargetName>
</PropertyGroup>
<Target Name="ReferencedPathMaps" BeforeTargets="CoreCompile" DependsOnTargets="ResolveProjectReferences" >
<MSBuild Projects="@(AnnotatedProjects->'%(FullPath)')"
Targets="$(_CoverletSourceRootTargetName)"
Properties="TargetFramework=%(AnnotatedProjects.NearestTargetFramework)"
SkipNonexistentTargets="true">
<Output TaskParameter="TargetOutputs"
ItemName="_LocalTopLevelSourceRoot" />
</MSBuild>
<ItemGroup>
<_byProject Include="@(_LocalTopLevelSourceRoot->'%(MSBuildSourceProjectFile)')" OriginalPath="%(Identity)" />
<_mapping Include="@(_byProject->'%(Identity)|%(OriginalPath)=%(MappedPath)')" />
</ItemGroup>
<PropertyGroup>
<_sourceRootMappingFilePath>$([MSBuild]::EnsureTrailingSlash('$(OutputPath)'))CoverletSourceRootsMapping_$(AssemblyName)</_sourceRootMappingFilePath>
</PropertyGroup>
<WriteLinesToFile File="$(_sourceRootMappingFilePath)" Lines="@(_mapping)"
Overwrite="true" Encoding="Unicode"
Condition="'@(_mapping)'!=''"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(_sourceRootMappingFilePath)" Condition="'@(_mapping)'!=''" />
</ItemGroup>
</Target>
<Target Name="InstrumentModules" Condition="'$(TargetPath)' != ''">
<Coverlet.MSbuild.Tasks.InstrumentationTask
Path="$(TargetPath)"
Include="$(Include)"
IncludeDirectory="$(IncludeDirectory)"
Exclude="$(Exclude)"
ExcludeByFile="$(ExcludeByFile)"
ExcludeByAttribute="$(ExcludeByAttribute)"
IncludeTestAssembly="$(IncludeTestAssembly)"
SingleHit="$(SingleHit)"
MergeWith="$(MergeWith)"
UseSourceLink="$(UseSourceLink)"
SkipAutoProps="$(SkipAutoProps)"
DeterministicReport="$(DeterministicReport)"
DoesNotReturnAttribute="$(DoesNotReturnAttribute)"
ExcludeAssembliesWithoutSources="$(ExcludeAssembliesWithoutSources)">
<Output TaskParameter="InstrumenterState" PropertyName="InstrumenterState"/>
</Coverlet.MSbuild.Tasks.InstrumentationTask>
</Target>
<Target Name="InstrumentModulesNoBuild"
BeforeTargets="VSTest"
DependsOnTargets="InstrumentModules"
Condition="'$(VSTestNoBuild)' == 'true' and '$(CollectCoverage)' == 'true'" />
<Target Name="InstrumentModulesAfterBuild"
AfterTargets="BuildProject"
DependsOnTargets="InstrumentModules"
Condition="'$(VSTestNoBuild)' != 'true' and '$(CollectCoverage)' == 'true'" />
<Target Name="GenerateCoverageResult" Condition="'$(InstrumenterState)' != ''">
<PropertyGroup>
<_coverletMultiTargetFrameworksCurrentTFM Condition="'$(TargetFrameworks)' != ''" >$(TargetFramework)</_coverletMultiTargetFrameworksCurrentTFM>
</PropertyGroup>
<Coverlet.MSbuild.Tasks.CoverageResultTask
Output="$(CoverletOutput)"
OutputFormat="$(CoverletOutputFormat)"
Threshold="$(Threshold)"
ThresholdType="$(ThresholdType)"
ThresholdStat="$(ThresholdStat)"
InstrumenterState="$(InstrumenterState)"
CoverletMultiTargetFrameworksCurrentTFM="$(_coverletMultiTargetFrameworksCurrentTFM)">
<Output TaskParameter="ReportItems" ItemName="CoverletReport" />
</Coverlet.MSbuild.Tasks.CoverageResultTask>
</Target>
<Target Name="GenerateCoverageResultAfterTest"
AfterTargets="VSTest"
DependsOnTargets="GenerateCoverageResult"
Condition="'$(CollectCoverage)' == 'true'" />
</Project>