2

When the "run code analysis" is started in the Azure DevOps the following error is shown:

==============================================================================
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

So I can not get the final report as expected.

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
  • Could you share your configuration of this task? According to the error message, the file path of TRX file is incorrect, it should be generated default under s file which is D:a\1\s\TestResults. – Mengdi Liang Jul 03 '19 at 18:54
  • 1
    Have a look at [this](https://stackoverflow.com/questions/50479716/the-following-projects-do-not-have-a-valid-projectguid-and-were-not-built-using) SO question. Please provide more relevant information (SonarQube version, kind of project, ...) so we can help you. – Jeroen Heier Jul 03 '19 at 19:09
  • @MerlinLiang-MSFT, this is my first time working with SonarQube. My project is .Net Core (C #) and xUnit. How can I find this configuration file? The project is in Azure Devops. – Fábio Demétrio Rodrigues Jul 03 '19 at 19:25
  • What is your setting under Advanced? what;s the value of "sonar.cs.vstest.reportsPaths"? – Mengdi Liang Jul 04 '19 at 07:23

2 Answers2

4

In .Net core you must give to each project s special GUID.

So go to your each .csproj and inside the <PropertyGroup> add this line:

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

You can generate GUIDs to your projects here.

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
1

I was having the same issue in a pipeline, just remember to put the Sonar Prepare task before the build process and Sonar Analize at the end.

enter image description here

Cheers.

Unheilig
  • 16,196
  • 193
  • 68
  • 98