Azure DevOps - Sonarcloud - .net Core 3.1 - No results

I’m trying to scan a .netcore 3.1 project and I’m not getting any results.

I suspected that this was due to the sonarcloud scan not being done in main/master branch however I have done this with some other projects and they at least produced lines of code.

Is there any support for c# on .netcore 3.1?
Are there any known issues and can anyone identify any issues from the attached code below?

The only thing different in this project to the others we host is we don’t run any tests - we are expecting zero code coverage however would have expected some other results in other areas to be produced. Are tests required or can an analysis be run just on the build alone?

The process in the yaml file is as follows:

pool:
  vmImage: 'windows-latest'
# windows-2022
variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- checkout: self
  fetchDepth: 0
- task: DotNetCoreCLI@2
  displayName: 'Restore Packages'
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'select'
- task: SonarCloudPrepare@1
  inputs:
    SonarCloud: 'Sonarcloud_<REDACTED>_ImportTool'
    organization: '<REDACTED>-vsts'
    scannerMode: 'MSBuild'
    projectKey: '<REDACTED>-vsts_<REDACTED>-Import-Tool'
    projectName: '<REDACTED> Import Tool'
    extraProperties: 
- task: UseDotNet@2
  displayName: 'Use .NET Core 3.1 sdk'
  inputs:
    packageType: sdk
    version: '3.1.x'
- task: UseDotNet@2
  displayName: 'Install .Net 5 SDK'
  inputs:
    packageType: 'sdk'
    version: '5.0.301'
- task: DotNetCoreCLI@2
  displayName: 'Build <REDACTED>.App'
  inputs:
    command: 'build'
    projects: '<REDACTED>.App/<REDACTED>.App.csproj'
    arguments: '--configuration $(BuildConfiguration)  --output $(Build.BinariesDirectory)/<REDACTED>.App'
- task: DotNetCoreCLI@2
  displayName: 'Publish <REDACTED>.App'    
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '<REDACTED>.App/<REDACTED>.App.csproj'
    arguments: '--configuration $(buildConfiguration) --output 
$(Build.ArtifactStagingDirectory)/<REDACTED>.Application'
    zipAfterPublish: true
- task: MSBuild@1
  displayName: 'Build <REDACTED>'
  inputs:
    solution: '<REDACTED>/<REDACTED>.sqlproj'
    msbuildArguments: '/p:PublishProfile=$(Build.BinariesDirectory)\<REDACTED>\<REDACTED>.publish.xml /p:publishUrl=$(Build.SourcesDirectory)'

- task: SonarCloudAnalyze@1
- task: SonarCloudPublish@1
  inputs:
    pollingTimeoutSec: '300'

Hey there.

If all you’re doing in this PR is adding YAML to run the build… you won’t see any Lines of Code (because nothing is code, it’s all configuration). Pull Requests only raise issues on changed code.

Hi Colin,

Thank you for your response. It has been run on a shortlived branch within Azure DevOps not via a PR. Here is an example of some code that is running on another repo that I have added which has added the number of new lines. Even if my sonarcloud scan was clean with zero bugs I would have expected some lines of code to be displayed.

I still think there may be issues with .netcore 3.1.

Hey there.

A short-lived branch, for these purposes, has the same behavior as a Pull Request.

What happens if you run the analysis on your main branch?

Hi Colin,

Thanks for your response, I’ll have to get the yaml file pushed to master - will need to get this approved first. I’ll respond mid next week as it probably won’t happen today - we have a two public holidays this weekend.

Hi Colin,

Simply running the code in a master branch has produced some results.

I have ran the SonarCloud projects in branhes other than the master/main branches before and this has always produced results but not for this project.

I’m happy to close this case.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.