sonar-scanner-msbuild icon indicating copy to clipboard operation
sonar-scanner-msbuild copied to clipboard

Do not generate module related properties in `sonar-project.properties`

Open sebastien-marichal opened this issue 11 months ago • 3 comments

Since SonarQube 7.6, modules are deprecated. Right now, for each project .csproj, we still generate module related properties:

sonar.projectKey=exclusion
sonar.working.directory=C:\\projects\\Exclusion\\.sonarqube\\out\\.sonar
sonar.projectBaseDir=C:\\projects\\Exclusion
sonar.pullrequest.cache.basepath=C:\\projects\\Exclusion

615D01B7-CB50-4152-8998-434C1ABC3516.sonar.projectKey=exclusion:615D01B7-CB50-4152-8998-434C1ABC3516  # This is deprecated
615D01B7-CB50-4152-8998-434C1ABC3516.sonar.projectName=Exclusion  # This is deprecated
615D01B7-CB50-4152-8998-434C1ABC3516.sonar.projectBaseDir=C:\\projects\\Exclusion  # This is deprecated
615D01B7-CB50-4152-8998-434C1ABC3516.sonar.sourceEncoding=utf-8  # This is deprecated
615D01B7-CB50-4152-8998-434C1ABC3516.sonar.sources=\  # This is deprecated
"C:\\projects\\Exclusion\\Program.cs",\
"C:\\projects\\Exclusion\\web-client\\src\\app\\s\\p.service.spec.ts"

615D01B7-CB50-4152-8998-434C1ABC3516.sonar.test.inclusions=**/*.spec.ts  # This is deprecated
615D01B7-CB50-4152-8998-434C1ABC3516.sonar.cs.analyzer.projectOutPaths=\  # This is deprecated
"C:\\projects\\Exclusion\\.sonarqube\\out\\0"
615D01B7-CB50-4152-8998-434C1ABC3516.sonar.cs.roslyn.reportFilePaths=\  # This is deprecated
"C:\\projects\\Exclusion\\.sonarqube\\out\\0\\Issues.json"

615D01B7-CB50-4152-8998-434C1ABC3516.sonar.working.directory=C:\\projects\\Exclusion\\.sonarqube\\out\\.sonar\\mod0  # This is deprecated
sonar.visualstudio.enable=false

sonar.modules=615D01B7-CB50-4152-8998-434C1ABC3516 # This is deprecated

While it still works, there are properties that can sometimes generate warnings that confuse users, such as reported here.

The previous example will generate the following warning when invoking the scanner-cli during the end step:

WARN: Specifying module-relative paths at project level in the property 'sonar.exclusions' is deprecated. To continue matching files like 'web-client/src/app/s/p.service.spec.ts', update this property so that patterns refer to project-relative paths.

Which is due to the 615D01B7-CB50-4152-8998-434C1ABC3516.sonar.test.inclusions property in the file.

Known workaround

Do not set properties in the csproj but as a CLI parameter.

For the example above:

dotnet sonarscanner begin /k:<project-key> /d:sonar.token=<sq-token> /d:sonar.test.inclusions=**/*.spec.ts

sebastien-marichal avatar Mar 07 '24 10:03 sebastien-marichal