Analysis is not being publish in Sonar

Hi,

I’m trying to build an old .net framework 4.5.2 application using .yml file configuration in AzureDevops and I already fix some issues, but now my pipiline finish with success but they don’t publish sonar analysis to server.
One thing that I noticed, is that the SonarQubeAnalyze@5 task stop in this lines:

00:17:27.72  Writing processing summary to C:\Projects\PROJECT\_agents\_work\1\.sonarqube\out\ProjectInfo.log
Calling the TFS Processor executable...
Executing file C:\Projects\PROJECT\_agents\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.19.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.TFSProcessor.exe
  Args: ConvertCoverage C:\Projects\NetView\_agents\_work\1\.sonarqube\conf\SonarQubeAnalysisConfig.xml C:\Projects\NetView\_agents\_work\1\.sonarqube\out\sonar-project.properties 
  Working directory: C:\Projects\PROJECT\_agents\_work\1
  Timeout (ms):-1
  Process id: 17160
Attempting to locate the CodeCoverage.exe tool...
Attempting to locate the CodeCoverage.exe tool using setup configuration...
Attempting to locate the CodeCoverage.exe tool using registry...
WARNING: Failed to find the code coverage command line tool. Possible cause: Visual Studio is not installed, or the installed version does not support code coverage.
Process returned exit code 0
The TFS Processor has finished
Calling the SonarScanner CLI...
Executing file C:\Projects\PROJECT\_agents\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.19.1\classic-sonar-scanner-msbuild\sonar-scanner-4.8.1.3023\bin\sonar-scanner.bat
  Args: -Dsonar.scanAllFiles=true -Dproject.settings=C:\Projects\PROJECT\_agents\_work\1\.sonarqube\out\sonar-project.properties --from=ScannerMSBuild/5.15 --debug <sensitive data removed>
  Working directory: C:\Projects\PROJECT\_agents\_work\1
  Timeout (ms):-1
  Process id: 17012
Process returned exit code 0
The SonarScanner CLI has finished
00:17:28.018  Post-processing succeeded.

And I saw in other .net core case that after this steps, this task execute a lot of commands and print SUCCESS at the end.
I try to search any information in sonar and azure devops files, but without success.

This is my .yml file today:

pool: SelfHostedAgent-Windows

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
# Prepare Analysis Configuration task
- checkout: self
  fetchDepth: 1
  clean: true

- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: SonarQubePrepare@5
  displayName: 'Prepare analysis on SonarQube'
  inputs:
    SonarQube: 'SonarQube'
    scannerMode: 'MSBuild'
    projectKey: 'PROJECT_KEY'
    extraProperties: |
      sonar.cs.vscoveragexml.reportsPaths=$(Agent.TempDirectory)/**/*.opencover.xml
      sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/*.opencover.xml
      sonar.cs.xunit.reportsPaths=$(Agent.TempDirectory)/testresults.trx
      sonar.scm.disabled=true
      sonar.verbose=true

# DotNet build
- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

# SQ Run Code Analysis task - QC3
- task: SonarQubeAnalyze@5
  displayName: RUN SonarQube
  inputs:
    jdkversion: 'JAVA_HOME_17_X64'

# Complete the analysis and upload the results to the server
- task: SonarQubePublish@5
  displayName: 'Publish analysis results to SonarQube'

Cloud you help me?
I’m kind of lost right now, :slight_smile:

Hi,

Could you share your full, verbose log?

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@1
            inputs:
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'MSBuild'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
                sonar.verbose=true
        
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

 
Thx,
Ann

Sure @ganncamp

SonarQubeAnalyze_log.txt (202.3 KB)

Tks,
Fabrício

Hi Fabricio,

Thanks for the log file. Unfortunately, it didn’t tell me much more than the snippet you provided in your initial report. I’m going to flag this for more expert eyes.

 
Ann

Ok @ganncamp ! Thank you.
Just let me know if you need any other information.

Fabricio

1 Like

@ganncamp I remembered something …
Some days ago I replyed another topic about the same problem, but in that time I was executing sonar in my local environment. Here is the topic Sonarqube for .NET - Post Processing succeeded but there is no report in Dashboard.

I found solution for thar problem forcing sonar-scanner.bat execution after sonar offical commands.

It seems that we have same problem here.
But in AzureDevops I don’t know how to do that. if this could be a solution, can you help me with SonarQubeAnalyze@5 task?

Tks,
Fabrício

Add more information @ganncamp :slight_smile:

I found this thread SonarScanner for .net doesn’t sending result to server. that seams the same problem I’m facing now.

Maybe can help you with some analysis.

Fabrício

1 Like

Hi @ganncamp , more info for you.

I checked that the problem is really about calling sonar-scanner from SonarQubeAnalyze@5 task in AD.
I saw this because I created .ps1 file with the follow command to execute directly in my .yml file and the analysis start to show in Sonar web:

sonar-scanner "-Dsonar.token=TOKEN" "-Dsonar.projectKey=PROJECT_KEY" "-Dsonar.sources=." "-Dsonar.host.url=URL" "-Dsonar.scm.disabled=true"

But now I have another problem. For some reason, even I using .net analyser, I’m receiving the follow message and code like the next example isn’t recognized as a problem:

WARN: Your project contains C# files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the SonarScanner for .NET 5.x or higher, see SonarScanner for .NET

cliente = null;
cliente.Bairro = "Test";

I’m using sonar-scanner-6.1.0.83647-net-framework as sonar-scanner.

I know that you’re looking solution for the last problem, but can you help me with this too?

Fabrício

sonar-scanner_logs.txt (43.7 KB)

Hi Fabricio,

We try to keep it to one topic per thread. Otherwise it can get messy, fast. Normally I’d tell you to create a new thread for this, but there’s really nowhere to go with it; this is the result you get when you use the SonarScanner CLI for .NET code. There’s a reason we went to the trouble of creating and maintaining a whole separate SonarScanner for .NET. :slight_smile:

 
Ann

Hello @fabricioasv,

I see you are using a self-hosted agent for your pipeline.
Could you tell me what .NET dependencies are installed on this host (MSBuild version, installed runtimes…)?

Could also provide the log for the begin step (the SonarQubePrepare@5 task) as well as the build log?
Please don’t forget to add the /v:d to your MSBuild parameter if not already there.

Thank you,