You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sonarqube format clashes with DeterministicSourcePaths=true #668
when you have a test coverage report with DeterministicSourcePaths=true, paths will start with /_/ to indicate the source root of the compilation. When you convert a report like this to the Sonarqube format, it will use the same paths. These paths sadly don't satisfy the requirements of the format, which include the following for the path:
Its path attribute can be either absolute or relative to the project's base directory (root module).
Now I am not sure if this tool should be responsible for modifying the paths. I could totally understand if this is out of scope. On the other hand I could also understand if handling paths like this is out of scope for the "Sonarqube Generic test coverage report format" itself, considering that it's supposed to be generic. So I wanted to open this issue as a discussion about whether normalizing the paths for the coverage format is something this tool should do or not.
I just realized that GitHub also has the discussion feature and it is enabled on this repository. If this better fits there, maybe someone could move this issue, to a discussion.
That's why I thought maybe it could, for example, emit absolute paths and be spec-compliant that way. As I said, though, I am totally fine with this being out of scope.
Another option would be to supply a directory manually via the -sourcedirs:.... command line parameter. Maybe that worth a try for you.
Thanks, unfortunately I already tried providing the command line parameter before writing this issue and noticed that it does not cause ReportGenerator to actually change the paths, when converting a report to the Sonarqube format. As far as I understand, it is only used to load the files for some other tasks.
I just thought this tool supporting something like -sourcedirs:... -convertPathsToAbsolute for converting a report might be something that's worth implementing, considering the SonarQube format does not support the deterministic path style.
(And then maybe defaulting to true for that option if the format is SonarQube, since it seems like a sane default.)
Anyway, I will try the manual replacement; that should work too. Thanks for the suggestion.
Same problem here:
Providing source dirs allows ReportGenerator to find the sources and display it but does not change the path's e.g. in Sonar XML file. @danielpalme Out of the box support for that would be nice
In 1eb5e17 I made a change to the SonarQube export.
SonarQube report now exports mapped/absolute paths if they got modified by the given source directories
Activity
JustusGreiberORGADATA commentedon May 13, 2024
I just realized that GitHub also has the discussion feature and it is enabled on this repository. If this better fits there, maybe someone could move this issue, to a discussion.
danielpalme commentedon May 13, 2024
In your case you can use a little Powershell script to set the correct the path information. This might look like the following example:
ReportGenerator can't guess the correct path in that case.
JustusGreiberORGADATA commentedon May 14, 2024
Interesting, I thought ReportGenerator in some cases already does try to determine the right paths here:
https://github.com/danielpalme/ReportGenerator/blob/main/src/ReportGenerator.Core/Parser/FileReading/LocalFileReader.cs#L106-L168
That's why I thought maybe it could, for example, emit absolute paths and be spec-compliant that way. As I said, though, I am totally fine with this being out of scope.
danielpalme commentedon May 14, 2024
https://github.com/danielpalme/ReportGenerator/blob/main/src/ReportGenerator.Core/Parser/FileReading/LocalFileReader.cs#L106-L168
Correct. But this only works (automatically) if you are using Azure DevOps or Github Actions.
Another option would be to supply a directory manually via the
-sourcedirs:....command line parameter.Maybe that worth a try for you.
JustusGreiberORGADATA commentedon May 14, 2024
Thanks, unfortunately I already tried providing the command line parameter before writing this issue and noticed that it does not cause ReportGenerator to actually change the paths, when converting a report to the Sonarqube format. As far as I understand, it is only used to load the files for some other tasks.
I just thought this tool supporting something like
-sourcedirs:... -convertPathsToAbsolutefor converting a report might be something that's worth implementing, considering the SonarQube format does not support the deterministic path style.(And then maybe defaulting to true for that option if the format is SonarQube, since it seems like a sane default.)
Anyway, I will try the manual replacement; that should work too. Thanks for the suggestion.
Sam13 commentedon Oct 30, 2026
Same problem here:
Providing source dirs allows ReportGenerator to find the sources and display it but does not change the path's e.g. in Sonar XML file.
@danielpalme Out of the box support for that would be nice
#668 SonarQube report now exports mapped/absolute paths gets modified…
#668 SonarQube report now exports mapped/absolute paths gets modified…
danielpalme commentedon Nov 8, 2026
In 1eb5e17 I made a change to the SonarQube export.
SonarQube report now exports mapped/absolute paths if they got modified by the given source directories
ReportGenerator/src/ReportGenerator.Core/Reporting/Builders/SonarQubeBuilder.cs
Line 73 in 1eb5e17
I will include this feature in the next release. I will publish it once .NET 11 is available.