【问题标题】:Error in SonarQube when "run code analysis" starts in Azure DevOps在 Azure DevOps 中启动“运行代码分析”时 SonarQube 出错
【发布时间】:2019-11-14 12:11:37
【问题描述】:

在 Azure DevOps 中启动“运行代码分析”时,会显示以下错误:

==============================================================================
Task         : Run Code Analysis
Description  : Run scanner and upload the results to the SonarCloud server.
Version      : 1.6.3
Author       : sonarsource
Help         : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================
[command]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.6.3\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 4.6.2
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
17:36:00.872  Fetching code coverage report information from TFS...
17:36:00.872  Attempting to locate a test results (.trx) file...
17:36:00.92  Looking for TRX files in: D:\a\1\TestResults
17:36:00.92  No test results files found
17:36:00.951  Did not find any binary coverage files in the expected location.
17:36:00.951  Falling back on locating coverage files in the agent temp directory.
17:36:00.951  Searching for coverage files in D:\a\_temp
17:36:00.951  No coverage files found in the agent temp directory.
WARNING: The following projects do not have a valid ProjectGuid and were not built using a valid solution (.sln) thus will be skipped from analysis...
D:\a\1\s\Domain.Core\Domain.Core.csproj, D:\a\1\s\Shared\Shared.csproj, D:\a\1\s\API\API.csproj, D:\a\1\s\Domain.Core\Domain.Core.csproj, D:\a\1\s\Shared\Shared.csproj, D:\a\1\s\Domain.Wallet\Domain.Wallet.csproj, D:\a\1\s\Domain.Store\Domain.Stores.csproj, D:\a\1\s\Domain.Order\Domain.Orders.csproj, D:\a\1\s\Domain.Users\Domain.Users.csproj, D:\a\1\s\App\App.csproj, D:\a\1\s\Domain.Core\Domain.Core.csproj, D:\a\1\s\Domain.Core\Domain.Core.csproj, D:\a\1\s\Domain.Store\Domain.Stores.csproj, D:\a\1\s\Shared\Shared.csproj, D:\a\1\s\Domain.Store\Domain.Stores.csproj, D:\a\1\s\Domain.Order\Domain.Orders.csproj, D:\a\1\s\Domain.Core\Domain.Core.csproj, D:\a\1\s\Shared\Shared.csproj, D:\a\1\s\Domain.Store\Domain.Stores.csproj, D:\a\1\s\Domain.Core\Domain.Core.csproj, D:\a\1\s\Shared\Shared.csproj, 
WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: "D:\a\1\s\Domain.Core\Domain.Core.csproj"
WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: 
##[error]No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
##[error]17:36:01.201  Post-processing failed. Exit code: 1
17:36:01.201  Post-processing failed. Exit code: 1
##[error]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.6.3\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe failed with return code: 1
##[section]Finishing: Run Code Analysis

所以我无法按预期得到最终报告。

【问题讨论】:

  • 你能分享你对这个任务的配置吗?根据报错信息,TRX文件的文件路径不对,应该是在s文件下默认生成的,即D:a\1\s\TestResults。
  • 看看this SO 问题。请提供更多相关信息(SonarQube 版本、项目类型……),以便我们为您提供帮助。
  • @MerlinLiang-MSFT,这是我第一次使用 SonarQube。我的项目是 .Net Core (C#) 和 xUnit。我怎样才能找到这个配置文件?该项目位于 Azure Devops 中。
  • 高级下的设置是什么? “sonar.cs.vstest.reportsPaths”的值是什么?

标签: azure-devops sonarqube azure-pipelines


【解决方案1】:

在 .Net 核心中,您必须为每个项目指定特殊的 GUID。

因此,转到您的每个 .csproj 并在 <PropertyGroup> 内添加以下行:

# Replace the guid here with a new one
<ProjectGuid>{13212313-gd5543-1321-3fdf1-313fdfs13}</ProjectGuid>

您可以为您的项目生成 GUID here

【讨论】:

    【解决方案2】:

    我在管道中遇到了同样的问题,请记住将 Sonar Prepare 任务放在构建过程之前,并将 Sonar Analize 放在最后。

    干杯。

    【讨论】:

      猜你喜欢
      • 2021-01-09
      • 2016-04-10
      • 2020-01-23
      • 2021-12-23
      • 2020-07-05
      • 2018-03-15
      • 2019-11-08
      • 1970-01-01
      • 2021-12-13
      相关资源
      最近更新 更多