I switched my project from “old” format (ToolsVersion="12.0"
) to sdk format (Sdk="Microsoft.NET.Sdk.WindowsDesktop"
). After that the code coverage is calculated with 0%.
In addition to this change the following items were changed in timely correlation, even I guess there are irrelevant:
- SQ Server update from
8.8.0
to8.9.1
- update of referenced NuGet packages, like xunit.runner.visualstudio from
2.4.1
to2.4.3
The analyzer remains unchanged:SonarScanner for MSBuild 5.0.4
.
I analyzed the logfiles of the first analysis (old format, coverage around 90%) and new analysis (sdk format, coverage 0%) and identified the following differences:
- New Warning:
File 'C:\Users\***\.nuget\packages\***\1.1.18\build\net40\***.dll' is not located under the root directory 'c:\buid\_work\298\s' and will not be analyzed.
This should not be relevant because this not in focus for the analyzed project. - The
Sensor C# Tests Coverage Report Import [csharp]
reports
DEBUG: Pattern matcher extracted prefix/absolute path 'c:\buid\_work\298\s\TestResults' from the given pattern 'c:\buid\_work\298\s/TestResults/**/*.coveragexml'
.
In the successful analysis the matcher extracted the path “c:\build\_work\317” without “s/TestResults” with similar input:
DEBUG: Pattern matcher extracted prefix/absolute path 'c:\build\_work\317' from the given pattern 'c:\build\_work\317\s/TestResults/**/*.coveragexml'.
I guess this is interesting but I do not have an explanation for the behavior. (Maybe this is not relevant because this output is only from coveragexml file identification.) - Later the cs files from test project are identified and listed to be ignored. This results now in the following summary:
DEBUG: The total number of file count statistics is '25'.
INFO: Coverage Report Statistics: 25 files, 0 main files, 0 main files with coverage, 25 test files, 0 project excluded files, 0 other language files.
The Code Coverage report doesn't contain any coverage data for the included files. Troubleshooting guide: https://community.sonarsource.com/t/37151
In the successful analysis this looks like follows:
DEBUG: The total number of file count statistics is '80'.
INFO: Coverage Report Statistics: 80 files, 55 main files, 55 main files with coverage, 25 test files, 0 project excluded files, 0 other language files.
The cs files from “real” project are not identified anymore.
I checked the mentioned Troubleshooting Guide but did not identify helpful information for my problem:
- The files to be analyzed are listed with
indexed with language 'cs'
- The coverage file is identified and converted to converagexml by the analyzer:
INFO: Parsing the Visual Studio coverage XML report c:\buid\_work\298\s\TestResults\***_2021-08-31_10_38_19\In\***\***_2021-08-31.10_38_11.coveragexml
I have other projects analyzed correctly in sdk file format. But I think this is the most relevant change (of identified differences).