Sonarqube 在不同的文件夹中产生不同的结果

Sonarqube producing different results in different folders

更新 1:

它实际上与构建服务器无关,我已将我的 repo 检出到一个新文件夹中并且可以观察到相同的行为,因此这绝对不是版本问题。我比较了 .sonarqube 文件夹,没有发现任何异常。什么可能导致从另一个位置构建时忽略一个 csproj 的结果?

原题:

我正在为一个 .net 项目(1 .sln,2 .csproj)设置 sonarqube,当我 运行 在我的机器上进行分析时它起作用了,所有文件都被分析了,我得到了一个不错的报告。

当我 运行 在新的构建服务器上时,只有上传了一个 .csproj 的结果。

我已经验证了相同版本的 msbuild 和声纳扫描仪。

我在输出中看到的一些差异是:

  1. 构建服务器上没有要分析的文件:

本地:

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

构建服务器:

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. 索引 CPD 块时文件数量不同

本地:

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[=12=]\output-cs'
WARNING: WARN:   * ${filename}.cs
  // 5 more files
INFO: Importing results from 6 proto files in '${projectDir}\.sonarqube\out\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}

构建服务器:

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[=13=]\output-cs'
INFO: Importing results from 6 proto files in '${projectDir}\.sonarqube\out\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}

我运行使用这些命令进行分析:

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"

尝试触发第二个命令 MSBuild.exe 1.sln /t:重建

检查该解决方案有多少个项目。 2.csproj 应该是 1.sln

的一部分

已解决,MsBuild 对文件夹名称不区分大小写,Sonarqube 是。

我的解决方案文件引用了

My.Project1/My.Project1.csproj 但在源代码管理中文件夹被命名为 MY.Project1/My.Project1.csproj

不知何故在我的本地机器上我有工作文件夹名称。