Analyze .NET Core solution with SonarCloud and Github Actions


I’d like to analyze my .NET Core solution with SonarCloud in Github Actions.
Is this a supported scenario?
I followed the instructions at and added the SonarCloud step to my workflow:

  • name: SonarCloud Scan
    uses: sonarsource/sonarcloud-github-action@master

It fails with the following error:

Run sonarsource/sonarcloud-github-action@master
DOTNET_ROOT: C:\hostedtoolcache\windows\dncs\2.2.108\x64
##[error]Container action is only supported on Linux

I configured the SONAR_TOKEN in my GitHub settings as suggested, but I don’t see any GITHUB_TOKEN in my repo secrets. Is that a built-in token on Github?

Update: Resolved.
My GitHub Actions workflow was configured for Windows. This was no problem up until the SonarCloud task. I now configured it to run on Linux and now the workflow succeeds across the board.

name: .NET Core
on: [push]
        runs-on: ubuntu-latest
1 Like


I’m curious how well the Action worked? On the marketplace page it lists .NET solutions under “Do not use this GitHub action if you are in the following situations” I guess it’s because the action uses the SonarScanner CLI instead of the SonarScanner for MSBuild/DotNet Core.

I was looking around for alternatives in other Sonar DotNet Core Actions in the marketplace, but I couldn’t find anyone that supported pull request decoration. So I developed my own Action for this:

1 Like

I am not having good luck trying to get this to work… So, they are probably correct.

I’m not using the action from the market place any more.
Instead, in my GitHub Actions workflow, I install the global tool dotnet-sonarscanner to analyze my code.
As a prereq, I’m also installing Java in a step for the global tool to work.

You can see an example here:

1 Like