I cover a Blazor application with xUnit tests.
My generated report contains references to .razor files crashing the scanner :
INFO: Scanner configuration file: C:\Users\Lefebvreo\.dotnet\tools\.store\dotnet-sonarscanner\4.8.0\dotnet-sonarscanner\4.8.0\tools\netcoreapp3.0\any\sonar-scanner-4.2.0.1873\bin\..\conf\sona
r-scanner.properties
INFO: Project root configuration file: C:\Projects\Perso\TheIdServer\.sonarqube\out\sonar-project.properties
INFO: SonarQube Scanner 4.2.0.1873
...
INFO: Parsing C:\Projects\Perso\TheIdServer\coverage\SonarQube.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:47.675s
INFO: Final Memory: 16M/57M
dotnet : ERROR: Error during SonarQube Scanner execution
At C:\Projects\Perso\TheIdServer\build.ps1:39 char:2
+ dotnet sonarscanner end -d:sonar.login=$env:sonarqube
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (ERROR: Error du...anner execution:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
INFO: ------------------------------------------------------------------------
ERROR: Error during parsing of the generic coverage report 'C:\Projects\Perso\TheIdServer\coverage\SonarQube.xml'. Look at SonarQube documentation to know the expected XML format.
ERROR: Caused by: Line 8580 of report refers to a file with an unknown language:
C:\Projects\Perso\TheIdServer\src\Aguacongas.TheIdServer.BlazorApp\Components\ApiComponents\ApiClaimTypes.razor
ERROR:
The SonarQube Scanner did not complete successfully
10:41:05.902 Post-processing failed. Exit code: 1
coverage\SonarQube.xml
<?xml version="1.0" encoding="utf-8"?>
<coverage version="1">
...
<file path="C:\Projects\Perso\TheIdServer\src\Aguacongas.TheIdServer.BlazorApp\Components\ApiComponents\ApiClaimTypes.razor">
<lineToCover lineNumber="6" covered="true" branchesToCover="2" coveredBranches="2" />
<lineToCover lineNumber="10" covered="false" />
<lineToCover lineNumber="11" covered="false" />
</file>
...
.razor files should be treated as .cshtml files.
If I exclude **/*.razor from my coverage report it works and I’ve .cshtml files.
Full code and build script can be found here
To enable .razor file in the report remove <ExcludeByFile>**/*.razor</ExcludeByFile>
from coverletArgs.runsettings