SonarQube-仪表板上未显示C#代码

SonarQube-仪表板上未显示C#代码,c#,sonarqube,C#,Sonarqube,我对SonarQube 6.7有一个问题,它没有显示任何C#代码问题或bug,在分析过程中,我可以看到C#正在被分析,构建成功,但当我检查SonarQube仪表板时,它只显示Typescript和XML 我使用Jenkins使用Mono构建项目,因为我们所有的构建都是在Ubuntu 16.04上完成的 设置如下: Ubuntu 16.04上的Jenkins 2.89.2 Ubuntu 16.04(独立服务器)上的SonarQube版本6.7(构建33306) 声纳C#6.8.1 用于MSBuil

我对SonarQube 6.7有一个问题,它没有显示任何C#代码问题或bug,在分析过程中,我可以看到C#正在被分析,构建成功,但当我检查SonarQube仪表板时,它只显示Typescript和XML

我使用Jenkins使用Mono构建项目,因为我们所有的构建都是在Ubuntu 16.04上完成的

设置如下:

Ubuntu 16.04上的Jenkins 2.89.2

Ubuntu 16.04(独立服务器)上的SonarQube版本6.7(构建33306)

声纳C#6.8.1

用于MSBuild 4.0.1的SonarQube扫描仪

Mono 5.10.0稳定版

使用Jenkins中的管道,我正在执行以下操作:

node {
    sh 'mono ~/tools/hudson.plugins.sonar.MsBuildSQRunnerInstallation/MSBuild/SonarQube.Scanner.MSBuild.exe begin /key:12345678FAKEKEY9l02998745'
    sh 'dotnet restore WSP1.sln'
    sh 'dotnet msbuild WSP1.sln'
    sh 'mono ~/tools/hudson.plugins.sonar.MsBuildSQRunnerInstallation/MSBuild/SonarQube.Scanner.MSBuild.exe end' } }
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for ts: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: Sensor C# Properties [csharp]
WARNING: WARN: Property missing: 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for this project.
WARNING: WARN: No roslyn issues report not found for this project.
INFO: Sensor C# Properties [csharp] (done) | time=1ms
上面的管道脚本可以正常工作,没有任何问题

当我运行这个管道时,我可以看到正在分析C代码,这只是正在分析的代码片段:

Services/Project1/Services/Project1EventsShould.cs(130,21): warning S1186: Add a nested comment explaining why this method is empty, throw a 'NotSupportedException' or complete the implementation. [/var/lib/jenkins/workspace/CSharpAnalysis/WSP1/test/Unit/Unit.csproj]
Services/Project1/Services/Project1EventsShould.cs(137,21): warning S1186: Add a nested comment explaining why this method is empty, throw a 'NotSupportedException' or complete the implementation. [/var/lib/jenkins/workspace/CSharpAnalysis/WSP1/test/Unit/Unit.csproj]
Services/Project1/Models/ZenEventShould.cs(24,17): warning S1481: Remove this unused 'date' local variable. [/var/lib/jenkins/workspace/CSharpAnalysis/WSP1/test/Unit/Unit.csproj]
Services/Project1/Models/CollaborationUserShould.cs(16,17): warning S1481: Remove this unused 'sut' local variable. [/var/lib/jenkins/workspace/CSharpAnalysis/WSP1/test/Unit/Unit.csproj]
最后我获得了成功,一切看起来都很好,但当我检查SonarQube时,我可以看到上传的代码正在分析,以便在SonarQube中显示,这通常需要一分钟左右,但完成后,我可以看到只显示TypeScript和XML

在输出中,我得到了一些警告、信息和错误,但没有什么看起来不安全,在输出的最后,我得到了成功消息

INFO: 68 files had no CPD blocks
INFO: Calculating CPD for 281 files
INFO: CPD calculation finished
INFO: Analysis report generated in 1771ms, dir size=5 MB
INFO: Analysis reports compressed in 3908ms, zip size=2 MB
INFO: Analysis report uploaded in 5866ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://sonar.serverdomain.com:9000/dashboard/index/12345678FAKEKEY9l02998745
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://sonar.serverdomain.com:9000/api/ce/task?id=AKsdHc7FAKEIDVOeCzBYv
INFO: Task total time: 1:32.107 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:42.735s
INFO: Final Memory: 54M/397M
INFO: ------------------------------------------------------------------------
The SonarQube Scanner has finished
14:59:57.577  Creating a summary markdown file...
14:59:57.59  Analysis results: http://sonar.serverdomain.com:9000/dashboard/index/12345678FAKEKEY9l02998745
14:59:57.591  Post-processing succeeded.
Finished: SUCCESS
我手边有完整的输出,我只需要对它进行消毒,去除任何可能敏感的东西,如果你想看一下,请让我知道,我会发布这个

我是个新手,所以我遇到的问题可能很愚蠢,但我一直在努力解决这个问题

编辑:我再次查看输出,注意到以下两个警告:

node {
    sh 'mono ~/tools/hudson.plugins.sonar.MsBuildSQRunnerInstallation/MSBuild/SonarQube.Scanner.MSBuild.exe begin /key:12345678FAKEKEY9l02998745'
    sh 'dotnet restore WSP1.sln'
    sh 'dotnet msbuild WSP1.sln'
    sh 'mono ~/tools/hudson.plugins.sonar.MsBuildSQRunnerInstallation/MSBuild/SonarQube.Scanner.MSBuild.exe end' } }
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for ts: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: Sensor C# Properties [csharp]
WARNING: WARN: Property missing: 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for this project.
WARNING: WARN: No roslyn issues report not found for this project.
INFO: Sensor C# Properties [csharp] (done) | time=1ms

我刚刚在Sonarqube 6.7.4(build 38452)上遇到了同样的问题

通过两个步骤解决:

  • 在将内置SonarC#插件更新到7.2版(build 5463)(卸载-重启-安装-重启)并重新扫描后,出现了代码问题(漏洞、代码气味等)
  • 将包引入测试项目以生成覆盖率数据,配置项目-管理-C#-OpenCover单元测试报告路径以使用
    path/to/coverage.OpenCover.xml
    。重新扫描后,显示测试覆盖率数据
  • 以下是在上述配置之后执行的所有命令:

        dotnet path/to/SonarScanner.MSBuild.dll begin /k:"project-key"
        dotnet build
        dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
        dotnet path/to/SonarScanner.MSBuild.dll end
    

    能否使用
    /v:diag
    运行生成步骤,并告诉我是否可以看到以下警告:
    \.sonaqube\bin\targets\sonaqube.Integration.targets(261,5):警告:项目没有有效的ProjectGuid。此项目的分析结果将不会上载到SonarQube。项目文件:
    ?当我第一次开始这个项目时,我收到了ProjectGuid消息,但我已经解决了这个问题。我用v:diag再次运行了这个,没有看到ProjectGuid消息。还有什么我能注意到的吗?可能是同一个问题吗?我通过shell尝试了上面的所有步骤,得到了相同的问题。;我已经更新了原来的帖子,因为我发现了两条可能相关的警告。@AmauryLevé你还有什么我可以注意的吗?