8
votes

I tried to change the module name of a C# project by adding the following xml fragment to my csproj file:

<ItemGroup> 
    <SonarQubeSetting Include="sonar.projectName">
        <Value>Core.XY</Value>
    </SonarQubeSetting>
</ItemGroup>

This works the way I expected (module name in SonarQube is set accordingly).

Question: Is this supported or does it just work by accident? I do not really want to use this behavior if I have to fear that it changes with the next upgrade.

The sonar-project.properties files that is generated contains these entries:

B6CCB06F-640A-428E-8A4E-4BBBAD881400.sonar.projectName=XY
...
B6CCB06F-640A-428E-8A4E-4BBBAD881400.sonar.projectName=Core.XY

This could mean that my configuration works more or less by accident.


Update: The following explains why I want to change the module name of some projects: I have several Solutions with projects, e.g.

Core.sln
- Lib.csproj
- Tools.csproj
Service.sln
- Lib.csproj
- ...

In this situation I end up with two "Lib" modules in SonarQube unless I have a way of overriding the module name. I could of course rename the projects, but I would rather be able to simply tell SonarQube which module name to use.

I would also be very happy if Sonar Scanner would use the assembly name instead of the project name.

1
Indeed Stefan, we can't really say that this was done on purpose and so I would prefer understanding why the default module name doesn't fit your need. Thanks - Freddy - SonarSource Team
Thanks. I updated my question... - Stefan Egli

1 Answers

0
votes

I believe, you can use this setting. "SonarQubeSetting" and "sonar.projectName" will set the project name correctly.

Refer link and link to learn more on this.