Sonarqube producing different results in different folders

微笑、不失礼 提交于 2019-12-24 18:45:42

问题


Update 1:

It is actually not related to the build server, I have checkout my repo into a fresh folder and can observe the same behavior so it definitely isn't a version problem. I have compared the .sonarqube folders and cannot see anything unusual. What could be causing the results from one csproj to be ignored when building from another location?

Original question:

I'm setting up sonarqube for a .net project (1 .sln, 2 .csproj), when I run the analysis on my machine it works, all the files are analysed and I get a nice report.

When I run on the new build server only results from one of the .csproj is uploaded.

I have verified the same versions of msbuild and sonar scanner.

some differences I see in the output are:

  1. No files to be analysed on build server:

local:

INFO: Index files
INFO: 84 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: SCM provider for this project is: git
INFO: 39 files to be analyzed
INFO: 0/39 files analyzed

build server:

INFO: Index files
INFO: 86 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=2ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
  1. different number of files when indexing CPD blocks

local:

INFO: Index files
INFO: 0 files indexed
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor C# [csharp]
WARNING: WARN:   * ${filename}.cs
WARNING: WARN:   * ${filename}.cs
INFO: Importing results from 6 proto files in '${projectDir}\.sonarqube\out\0\output-cs'
WARNING: WARN:   * ${filename}.cs
  // 5 more files
INFO: Importing results from 6 proto files in '${projectDir}\.sonarqube\out\1\output-cs'
WARNING: WARN:   * ${filename}.cs
  // 18 more files
WARNING: WARN: This may lead to missing/broken features in SonarQube
INFO: Importing 2 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=5245ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=143ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=5ms
INFO: 7 files had no CPD blocks
INFO: Calculating CPD for 71 files
INFO: CPD calculation finished
INFO: Analysis report generated in 3159ms, dir size=468 KB
INFO: Analysis reports compressed in 881ms, zip size=256 KB
INFO: Analysis report uploaded in 287ms
INFO: ANALYSIS SUCCESSFUL, you can browse ${sonarUrl}

build server:

INFO: Index files
INFO: 0 files indexed
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: Sensor C# [csharp]
INFO: Importing results from 6 proto files in '${projectDir}\.sonarqube\out\0\output-cs'
INFO: Importing results from 6 proto files in '${projectDir}\.sonarqube\out\1\output-cs'
INFO: Importing 2 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=652ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=85ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: 1 file had no CPD blocks
INFO: Calculating CPD for 2 files
INFO: CPD calculation finished
INFO: Analysis report generated in 2326ms, dir size=234 KB
INFO: Analysis reports compressed in 268ms, zip size=116 KB
INFO: Analysis report uploaded in 95ms
INFO: ANALYSIS SUCCESSFUL, you can browse ${sonarUrl}

I run the analysis with these commands:

SonarQube.Scanner.MSBuild.exe begin /k:"key" /d:sonar.host.url="url" /d:sonar.login="token"
MSBuild.exe /t:Rebuild
SonarQube.Scanner.MSBuild.exe end /d:sonar.login="token"

回答1:


Solved it, MsBuild is not case sensitive with regards to folder names, Sonarqube is.

My solution file had a reference to

My.Project1/My.Project1.csproj but in source control the folder was named MY.Project1/My.Project1.csproj

Somehow on my local machine I had the working folder name.




回答2:


Try triggering second command as MSBuild.exe 1.sln /t:Rebuild

Check how many projects part of that solution. 2.csproj should be part of 1.sln



来源:https://stackoverflow.com/questions/48783418/sonarqube-producing-different-results-in-different-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!