Skip to content

Commit 21d3964

Browse files
authored
generate Coverage report only for windows (#1550)
* generate Coverage report only for windows * use assemblyfilter for report * remove workaround "DeterministicBuild.targets" * add coverlet.msbuild.tasks.deps.json https://learn.microsoft.com/en-us/visualstudio/msbuild/tutorial-custom-task-code-generation?view=vs-2022#generate-and-embed-a-depsjson-file
1 parent c69d37e commit 21d3964

File tree

16 files changed

+22
-130
lines changed

16 files changed

+22
-130
lines changed

.config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"isRoot": true,
44
"tools": {
55
"dotnet-reportgenerator-globaltool": {
6-
"version": "5.1.24",
6+
"version": "5.1.26",
77
"commands": [
88
"reportgenerator"
99
]
1010
}
1111
}
12-
}
12+
}

DeterministicBuild.targets

Lines changed: 0 additions & 23 deletions
This file was deleted.

Directory.Build.targets

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
<Project>
2-
<!-- Deterministic build workaround -->
3-
<Import Project="$(RepoRoot)\DeterministicBuild.targets" />
42
</Project>

Documentation/DeterministicBuild.md

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,42 +28,6 @@ If you include `DeterministicReport` parameters for `msbuild` and `collectors` i
2828
```
2929

3030
As you can see we have empty `<sources />` element and the `filename` start with well known deterministic fragment `/_/...`
31-
**Deterministic build is supported without any workaround since version 3.1.100 of .NET Core SDK**
32-
33-
## Workaround only for .NET Core SDK < 3.1.100
34-
35-
At the moment, deterministic build works thanks to the Roslyn compiler emitting deterministic metadata if `DeterministicSourcePaths` is enabled. Take a look [here](https://github.com/dotnet/sourcelink/tree/master/docs#deterministicsourcepaths) for more information.
36-
37-
To allow Coverlet to correctly do its work, we need to provide information to translate deterministic paths to real local paths for every project referenced by the test project. The current workaround is to add at the root of your repo a `Directory.Build.targets` with a custom `target` that supports Coverlet resolution algorithm.
38-
39-
```xml
40-
<!-- This target must be imported into Directory.Build.targets -->
41-
<!-- Workaround. Remove once we're on 3.1.300+
42-
https://github.com/dotnet/sourcelink/issues/572 -->
43-
<Project>
44-
<PropertyGroup>
45-
<TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
46-
</PropertyGroup>
47-
<ItemGroup>
48-
<EmbeddedFiles Include="$(GeneratedAssemblyInfoFile)"/>
49-
</ItemGroup>
50-
<ItemGroup>
51-
<SourceRoot Include="$([MSBuild]::EnsureTrailingSlash($(NuGetPackageRoot)))" Condition="'$(NuGetPackageRoot)' != ''" />
52-
</ItemGroup>
53-
54-
<Target Name="CoverletGetPathMap"
55-
DependsOnTargets="InitializeSourceRootMappedPaths"
56-
Returns="@(_LocalTopLevelSourceRoot)"
57-
Condition="'$(DeterministicSourcePaths)' == 'true'">
58-
<ItemGroup>
59-
<_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
60-
</ItemGroup>
61-
</Target>
62-
</Project>
63-
64-
```
65-
66-
If you already have a `Directory.Build.targets` file on your repo root you can simply copy `DeterministicBuild.targets` (which can be found at the root of this repo) next to yours and import it in your targets file. This target will be used by Coverlet to generate, at build time, a file that contains mapping translation information, the file is named `CoverletSourceRootsMapping` and will be in the output folder of your project.
6731

6832
You can follow our [step-by-step sample](Examples.md)
6933

Documentation/Examples/MSBuild/DeterministicBuild/DeterministicBuild.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibrary1", "ClassLibra
99
EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8AE3B75E-33BA-4E07-AD78-2DBCC3392262}"
1111
ProjectSection(SolutionItems) = preProject
12-
DeterministicBuild.targets = DeterministicBuild.targets
1312
Directory.Build.props = Directory.Build.props
1413
Directory.Build.targets = Directory.Build.targets
1514
HowTo.md = HowTo.md

Documentation/Examples/MSBuild/DeterministicBuild/DeterministicBuild.targets

Lines changed: 0 additions & 23 deletions
This file was deleted.

Documentation/Examples/MSBuild/DeterministicBuild/HowTo.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ Calculating coverage result...
9797
+---------+------+--------+--------+
9898
```
9999

100-
You should see on output folder the coverlet source root mapping file generated.
100+
You should see on output folder the coverlet source root mapping file generated. The filename starts with 'CoverletSourceRootsMapping_'.
101101
This is the confirmation that you're running coverage on deterministic build.
102102

103103
```text
104-
Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\net6.0\CoverletSourceRootsMapping
104+
Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\net6.0\CoverletSourceRootsMapping_XUnitTestProject1
105105
```

Documentation/Examples/VSTest/DeterministicBuild/DeterministicBuild.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibrary1", "ClassLibra
99
EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8AE3B75E-33BA-4E07-AD78-2DBCC3392262}"
1111
ProjectSection(SolutionItems) = preProject
12-
DeterministicBuild.targets = DeterministicBuild.targets
1312
Directory.Build.props = Directory.Build.props
1413
Directory.Build.targets = Directory.Build.targets
1514
HowTo.md = HowTo.md

Documentation/Examples/VSTest/DeterministicBuild/DeterministicBuild.targets

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
<Project>
2-
<!-- Deterministic build workaround -->
3-
<Import Project="$(MSBuildThisFileDirectory)DeterministicBuild.targets" />
42
</Project>

0 commit comments

Comments
 (0)