8

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.

Stefan Egli
  • 17,398
  • 3
  • 54
  • 75

1 Answers1

0

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.

Vikas Jindal
  • 249
  • 3
  • 12
  • Yes it does work, but it is not clear that this intended to work for the "projectName" property. The MSBuild Scanner sets this property automatically and therefore the property is set twice and just by good luck my property is used.... – Stefan Egli Oct 05 '16 at 06:46