Skip to content

Commit 1cc039f

Browse files
committed
Update project for .NET 8.0 and improve documentation
- Add notable changes section in `Changelog.md` for .NET 8.0 LTS upgrade and xUnit updates. - Revise `HowTo.md` for prerequisites on deterministic builds and local NuGet package generation. - Modify `KnownIssues.md` for assembly resolution behavior and `CopyLocalLockFileAssemblies`. - Update `ReleasePlan.md` with new package versions for `coverlet.msbuild` and `coverlet.collector`. - Revise `Troubleshooting.md` for output directory changes and local build instructions. - Update `VSTestIntegration.md` for new minimum version requirements for .NET SDK and `coverlet.collector`. - Update CI configuration files to install .NET SDK version 8.0.411. - Update `global.json` to specify .NET SDK version 8.0.411.
1 parent 9934cff commit 1cc039f

File tree

20 files changed

+171
-222
lines changed

20 files changed

+171
-222
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,4 @@ FolderProfile.pubxml
318318
/NuGet.config
319319
nuget.config
320320
*.dmp
321+
Playground*/

Documentation/Changelog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -7,12 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
78
## Unreleased
89

910
### Fixed
11+
1012
- Fix branchpoint exclusion for sdk 8.0.407 [#1741](https://github.com/coverlet-coverage/coverlet/issues/1741)
1113
- Use `<TargetFramework>netstandard2.0</TargetFramework>` for _coverlet.collector_ and _coverlet.msbuild.tasks_ Packages´
1214

1315
### Improvements
14-
- Use [xunit.v3](https://xunit.net/docs/getting-started/v3/whats-new) for tests and example code
1516

17+
- Upgraded minimum required .NET SDK and runtime to .NET 8.0 LTS (Long Term Support) (**Breaking Change**)
18+
- Use [xunit.v3](https://xunit.net/docs/getting-started/v3/whats-new) for tests and example code
1619

1720
## Release date 2024-01-20
1821
### Packages
Lines changed: 26 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,34 @@
1-
To run test we need to generates packages to reference in on test project.
2-
Run from repo root
1+
# Using Deterministic Builds with Coverlet MSBuild Integration
2+
3+
## Prerequisites
4+
5+
Before running tests with deterministic builds, you need to generate the local NuGet packages:
36

47
```shell
5-
C:\git\coverlet
6-
λ dotnet pack
7-
Microsoft (R) Build Engine version 17.7.4+3ebbd7c49 for .NET Core
8-
Copyright (C) Microsoft Corporation. All rights reserved.
9-
10-
Restore completed in 73,36 ms for C:\git\coverlet\src\coverlet.core\coverlet.core.csproj.
11-
Restore completed in 73,41 ms for C:\git\coverlet\test\coverlet.testsubject\coverlet.testsubject.csproj.
12-
Restore completed in 73,33 ms for C:\git\coverlet\test\coverlet.tests.projectsample.excludedbyattribute\coverlet.tests.projectsample.excludedbyattribute.csproj.
13-
Restore completed in 73,34 ms for C:\git\coverlet\src\coverlet.collector\coverlet.collector.csproj.
14-
Restore completed in 73,35 ms for C:\git\coverlet\test\coverlet.tests.xunit.extensions\coverlet.tests.xunit.extensions.csproj.
15-
Restore completed in 75,92 ms for C:\git\coverlet\test\coverlet.integration.tests\coverlet.integration.tests.csproj.
16-
Restore completed in 73,41 ms for C:\git\coverlet\src\coverlet.console\coverlet.console.csproj.
17-
Restore completed in 73,36 ms for C:\git\coverlet\test\coverlet.tests.projectsample.empty\coverlet.tests.projectsample.empty.csproj.
18-
Restore completed in 73,47 ms for C:\git\coverlet\src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj.
19-
Restore completed in 73,37 ms for C:\git\coverlet\test\coverlet.core.tests.samples.netstandard\coverlet.core.tests.samples.netstandard.csproj.
20-
Restore completed in 76,37 ms for C:\git\coverlet\test\coverlet.collector.tests\coverlet.collector.tests.csproj.
21-
Restore completed in 77,05 ms for C:\git\coverlet\test\coverlet.integration.template\coverlet.integration.template.csproj.
22-
Restore completed in 77,2 ms for C:\git\coverlet\test\coverlet.core.performancetest\coverlet.core.performancetest.csproj.
23-
Restore completed in 87,7 ms for C:\git\coverlet\test\coverlet.core.tests\coverlet.core.tests.csproj.
24-
coverlet.core -> C:\git\coverlet\src\coverlet.core\bin\Debug\netstandard2.0\coverlet.core.dll
25-
coverlet.collector -> C:\git\coverlet\src\coverlet.collector\bin\Debug\netcoreapp2.0\coverlet.collector.dll
26-
coverlet.msbuild.tasks -> C:\git\coverlet\src\coverlet.msbuild.tasks\bin\Debug\netstandard2.0\coverlet.msbuild.tasks.dll
27-
coverlet.console -> C:\git\coverlet\src\coverlet.console\bin\Debug\net6.0\coverlet.console.dll
28-
Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.6.0.1-preview.6.g918cd179e0.nupkg'.
29-
Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.6.0.1-preview.6.g918cd179e0.snupkg'.
30-
Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.6.0.1-preview.6.g918cd179e0.nupkg'.
31-
Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.6.0.1-preview.6.g918cd179e0.snupkg'.
32-
Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.6.0.1-preview.6.g918cd179e0.nupkg'.
33-
Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.6.0.1-preview.6.g918cd179e0.snupkg'.
8+
# Run from repository root
9+
dotnet pack
3410
```
3511

36-
Add msbuild package version generated to `"..\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\XUnitTestProject1.csproj"`
12+
## Project Setup
13+
14+
Update your test project file `XUnitTestProject1.csproj`:
3715

3816
```xml
3917
<Project Sdk="Microsoft.NET.Sdk">
40-
4118
<PropertyGroup>
42-
<TargetFramework>net6.0</TargetFramework>
19+
<TargetFramework>net8.0</TargetFramework>
4320
<IsPackable>false</IsPackable>
4421
</PropertyGroup>
4522

4623
<ItemGroup>
4724
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
48-
<PackageReference Include="xunit.v3" Version="1.1.0" />
49-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
25+
<PackageReference Include="xunit.v3" Version="2.0.0" />
26+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
5027
<PrivateAssets>all</PrivateAssets>
5128
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
5229
</PackageReference>
53-
<!-- version comes from coverlet.msbuild.6.0.1-preview.8.gcb9b802a5f.nupkg -->
54-
<PackageReference Include="coverlet.msbuild" Version="coverlet.msbuild.6.0.1-preview.8.gcb9b802a5f.nupkg" >
30+
<!-- Use the version from your locally built package -->
31+
<PackageReference Include="coverlet.msbuild" Version="8.0.1-preview.8.gcb9b802a5f">
5532
<PrivateAssets>all</PrivateAssets>
5633
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5734
</PackageReference>
@@ -60,50 +37,25 @@ Add msbuild package version generated to `"..\Documentation\Examples\MSBuild\Det
6037
<ItemGroup>
6138
<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" />
6239
</ItemGroup>
63-
6440
</Project>
6541
```
6642

67-
Go to test project folder and run
43+
## Running Tests
44+
45+
Navigate to your test project directory and run:
6846

6947
```shell
70-
C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild (detbuilddocs -> origin)
71-
λ dotnet test /p:CollectCoverage=true /p:DeterministicSourcePaths=true
72-
Test run for C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\net6.0\XUnitTestProject1.dll(.NETCoreApp,Version=v6.0)
73-
Microsoft (R) Test Execution Command Line Tool Version 17.5.0
74-
Copyright (c) Microsoft Corporation. All rights reserved.
75-
76-
Starting test execution, please wait...
77-
78-
A total of 1 test files matched the specified pattern.
79-
80-
Test Run Successful.
81-
Total tests: 1
82-
Passed: 1
83-
Total time: 1,1471 Seconds
84-
85-
Calculating coverage result...
86-
Generating report 'C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\coverage.json'
87-
88-
+---------------+------+--------+--------+
89-
| Module | Line | Branch | Method |
90-
+---------------+------+--------+--------+
91-
| ClassLibrary1 | 100% | 100% | 100% |
92-
+---------------+------+--------+--------+
93-
94-
+---------+------+--------+--------+
95-
| | Line | Branch | Method |
96-
+---------+------+--------+--------+
97-
| Total | 100% | 100% | 100% |
98-
+---------+------+--------+--------+
99-
| Average | 100% | 100% | 100% |
100-
+---------+------+--------+--------+
48+
dotnet test /p:CollectCoverage=true /p:DeterministicSourcePaths=true
10149
```
10250

103-
You should see on output folder the coverlet source root mapping file generated. The filename starts with 'CoverletSourceRootsMapping_'. Do not use `--no-build` option
104-
This is the confirmation that you're running coverage on deterministic build e.g. `Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\net6.0\CoverletSourceRootsMapping_XUnitTestProject1`
51+
> **Important**: Do not use the `--no-build` option as it will prevent the generation of deterministic build artifacts.
10552
53+
## Verification
54+
55+
After running the tests, verify the deterministic build by checking for the source root mapping file:
10656

10757
```text
108-
Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\net6.0\CoverletSourceRootsMapping_XUnitTestProject1
58+
bin\Debug\net8.0\CoverletSourceRootsMapping_XUnitTestProject1
10959
```
60+
61+
The presence of this file confirms that your coverage report was generated with deterministic build settings.

Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
77
</PropertyGroup>
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
11-
<PackageReference Include="xunit.v3" Version="1.1.0" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
11+
<PackageReference Include="xunit.v3" Version="2.0.0" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1515
</PackageReference>
Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,57 @@
1-
**Run from solution root sln**
1+
# Merging Coverage Reports
22

3-
To merge report together you need to run separate test and merge in one `json` format file.
4-
Last command will join and create final needed format file.
3+
## Running Tests Separately
54

6-
```shell
7-
dotnet test XUnitTestProject1\XUnitTestProject1.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/
8-
dotnet test XUnitTestProject2\XUnitTestProject2.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json"
9-
dotnet test XUnitTestProject3\XUnitTestProject3.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat="opencover"
5+
To merge coverage reports, run tests for each project and combine them into a single file:
6+
7+
```bash
8+
# Generate coverage for first project
9+
dotnet test XUnitTestProject1/XUnitTestProject1.csproj \
10+
/p:CollectCoverage=true \
11+
/p:CoverletOutput=../CoverageResults/
12+
13+
# Merge coverage from second project
14+
dotnet test XUnitTestProject2/XUnitTestProject2.csproj \
15+
/p:CollectCoverage=true \
16+
/p:CoverletOutput=../CoverageResults/ \
17+
/p:MergeWith="../CoverageResults/coverage.json"
18+
19+
# Merge coverage from third project and generate final OpenCover report
20+
dotnet test XUnitTestProject3/XUnitTestProject3.csproj \
21+
/p:CollectCoverage=true \
22+
/p:CoverletOutput=../CoverageResults/ \
23+
/p:MergeWith="../CoverageResults/coverage.json" \
24+
/p:CoverletOutputFormat="opencover"
1025
```
1126

12-
You can merge also running `dotnet test` and merge with single command from a solution file, but you need to ensure that tests will run sequentially(`-m:1`). This slow down testing but avoid invalid coverage result.
27+
## Running Tests from Solution
1328

14-
```shell
15-
dotnet test /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat=\"opencover,json\" -m:1
29+
To merge coverage using a single command (requires sequential execution):
30+
31+
```bash
32+
dotnet test \
33+
/p:CollectCoverage=true \
34+
/p:CoverletOutput=../CoverageResults/ \
35+
/p:MergeWith="../CoverageResults/coverage.json" \
36+
/p:CoverletOutputFormat="opencover,json" \
37+
-m:1
1638
```
1739

18-
N.B. You need to specify `json` format plus another format(the final one), because Coverlet can only merge proprietary format. At the end you can delete temporary `coverage.json` file.
40+
> **Note**: Sequential execution (`-m:1`) ensures accurate coverage but increases test duration.
41+
42+
## Important Considerations
43+
44+
- Include `json` format alongside your desired output format
45+
- Coverlet only merges its proprietary JSON format
46+
- The temporary `coverage.json` file can be deleted after merging
1947

20-
You can also merge the coverage result and generate another valid format to export the content than opencover, like cobertura.
48+
## Example with Cobertura Output
2149

22-
```shell
23-
dotnet test /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat=\"cobertura,json\" -m:1
50+
```bash
51+
dotnet test \
52+
/p:CollectCoverage=true \
53+
/p:CoverletOutput=../CoverageResults/ \
54+
/p:MergeWith="../CoverageResults/coverage.json" \
55+
/p:CoverletOutputFormat="cobertura,json" \
56+
-m:1
2457
```

Documentation/Examples/MSBuild/MergeWith/XUnitTestProject1/XUnitTestProject1.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
10+
<PackageReference Include="coverlet.msbuild" Version="8.0.0">
1111
<PrivateAssets>all</PrivateAssets>
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>

Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/XUnitTestProject2.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
10+
<PackageReference Include="coverlet.msbuild" Version="8.0.0">
1111
<PrivateAssets>all</PrivateAssets>
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
15-
<PackageReference Include="xunit.v3" Version="1.1.0" />
16-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
15+
<PackageReference Include="xunit.v3" Version="2.0.0" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1919
</PackageReference>

Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/XUnitTestProject3.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
10+
<PackageReference Include="coverlet.msbuild" Version="8.0.0">
1111
<PrivateAssets>all</PrivateAssets>
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
15-
<PackageReference Include="xunit.v3" Version="1.1.0" />
16-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
15+
<PackageReference Include="xunit.v3" Version="2.0.0" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1919
</PackageReference>

0 commit comments

Comments
 (0)