更新1:
它实际上与构建服务器无关,我将我的repo签出到一个新文件夹中并且可以观察到相同的行为,因此它绝对不是版本问题。我比较了.sonarqube文件夹,看不到任何异常。从另一个位置构建时,可能导致一个csproj的结果被忽略的原因是什么?
原始问题:
我为.net项目设置了sonarqube(1 .sln,2 .csproj),当我在我的机器上运行分析时,它运行起来,所有文件都被分析了,我得到了一个很好的报告。 / p>
当我在新的构建服务器上运行时,只会上传一个.csproj的结果。
我已经验证了相同版本的msbuild和声纳扫描仪。
我在输出中看到的一些差异是:
本地:
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
本地:
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}
构建服务器:
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}
我使用以下命令运行分析:
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"
答案 0 :(得分:1)
解决了这个问题,MsBuild在文件夹名称方面不区分大小写,Sonarqube是。
我的解决方案文件引用了
My.Project1/My.Project1.csproj
但在源代码管理中,该文件夹名为MY.Project1/My.Project1.csproj
不知何故,在我的本地机器上,我有了工作文件夹名称。
答案 1 :(得分:0)
尝试触发第二个命令为 MSBuild.exe 1.sln / t:重建
检查该解决方案中有多少项目。 2.csproj应该是1.sln
的一部分