-
Notifications
You must be signed in to change notification settings - Fork 352
Expand file tree
/
Copy pathMicrosoft.CodeCoverage.targets
More file actions
60 lines (51 loc) · 3.73 KB
/
Microsoft.CodeCoverage.targets
File metadata and controls
60 lines (51 loc) · 3.73 KB
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
<!--
***********************************************************************************************
Microsoft.CodeCoverage.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your test projects from the command-line or the IDE.
Copyright (c) Microsoft. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This target required to enable /collect:"Code Coverage" in "dotnet publish" scenario with "dotnet vstest".
E.g: Release pipelines where user/project nuget cache not available on current machine. -->
<Target Name="CopyTraceDataCollectorArtifacts" AfterTargets="ComputeFilesToPublish">
<ItemGroup>
<TraceDataCollectorArtifacts Include="$(MSBuildThisFileDirectory)\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(TraceDataCollectorArtifacts)" DestinationFolder="$(PublishDir)%(RecursiveDir)" />
</Target>
<PropertyGroup Condition="'$(NETCoreSdkVersion)' != '' and '$(DisableMsCoverageReferencedPathMaps)' != 'true'">
<_msCoverageSdkNETCoreSdkVersion>$(NETCoreSdkVersion)</_msCoverageSdkNETCoreSdkVersion>
<_msCoverageSdkNETCoreSdkVersion Condition="$(_msCoverageSdkNETCoreSdkVersion.Contains('-'))">$(_msCoverageSdkNETCoreSdkVersion.Split('-')[0])</_msCoverageSdkNETCoreSdkVersion>
<_msCoverageSdkMinVersionWithDependencyTarget>6.0.100</_msCoverageSdkMinVersionWithDependencyTarget>
<_msCoverageSourceRootTargetName>MsCoverageGetPathMap</_msCoverageSourceRootTargetName>
<_msCoverageSourceRootTargetName Condition="'$([System.Version]::Parse($(_msCoverageSdkNETCoreSdkVersion)).CompareTo($([System.Version]::Parse($(_msCoverageSdkMinVersionWithDependencyTarget)))))' >= '0' ">InitializeSourceRootMappedPaths</_msCoverageSourceRootTargetName>
</PropertyGroup>
<!-- This target required to store deterministic sources mapping.
It is modified version of https://github.com/coverlet-coverage/coverlet/blob/d1ca364b7dbff38abce0457d94c4ce1b7e3a4cd9/src/coverlet.collector/build/coverlet.collector.targets#L35 -->
<Target Condition="'$(NETCoreSdkVersion)' != '' and '$(DisableMsCoverageReferencedPathMaps)' != 'true'" Name="MsCoverageReferencedPathMaps" BeforeTargets="CoreCompile" DependsOnTargets="ResolveProjectReferences" >
<MSBuild Projects="@(AnnotatedProjects->'%(FullPath)')"
Targets="$(_msCoverageSourceRootTargetName)"
Properties="TargetFramework=%(AnnotatedProjects.NearestTargetFramework)"
SkipNonexistentTargets="true">
<Output TaskParameter="TargetOutputs"
ItemName="_msCoverageLocalTopLevelSourceRoot" />
</MSBuild>
<ItemGroup>
<_msCoverageByProject Include="@(_msCoverageLocalTopLevelSourceRoot->'%(MSBuildSourceProjectFile)')" OriginalPath="%(Identity)" />
<_msCoverageMapping Include="@(_msCoverageByProject->'%(Identity)|%(OriginalPath)=%(MappedPath)')" />
</ItemGroup>
<PropertyGroup>
<_msCoverageSourceRootMappingFilePath>$([MSBuild]::EnsureTrailingSlash('$(OutputPath)')).msCoverageSourceRootsMapping_$(AssemblyName)</_msCoverageSourceRootMappingFilePath>
</PropertyGroup>
<WriteLinesToFile File="$(_msCoverageSourceRootMappingFilePath)" Lines="@(_msCoverageMapping)"
Overwrite="true" Encoding="Unicode"
Condition="'@(_msCoverageMapping)'!=''"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(_msCoverageSourceRootMappingFilePath)" Condition="'@(_msCoverageMapping)'!=''" />
</ItemGroup>
</Target>
</Project>