How to setup sonar in Gitlab Pipeline for C# (.Net platform) repository

Following are the details:

  • ALM used (Gitlab)
  • CI system used (Gitlab)
  • Scanner command used when applicable
  • Languages of the repository (C#)

I do not find any step for setting up C# project (.NET platform) in Sonar Cloud in Gitlab Pipeline.


Welcome to the community!

Can I take it from your other thread that you’ve figured this out?


No, this is still an issue as I found no documentation for this in Sonar. Can you help me how to set this up in pipeline?


It’s unfortunate that I don’t have a yaml snippet to give you. I’m going to raise that internally.

And in the meantime, you only need to script the steps you’ve already described in your other post.


While doing so, I get this error in Gitlab pipeline. I am running the sonarcloud so why is it asking for a sonarqube.analysis.xml

$ dotnet sonarscanner begin \ /o:<org> \ /k:<project> \ / dotnet sonarscanner end
SonarScanner for MSBuild 6.2
Using the .NET Core version of the Scanner for MSBuild
Invalid command line parameters. Please specify either 'begin' or 'end', not both.
Default properties file was found at /tmp/.dotnet/tools/.store/dotnet-sonarscanner/6.2.0/dotnet-sonarscanner/6.2.0/tools/netcoreapp3.1/any/SonarQube.Analysis.xml
Loading analysis properties from /tmp/.dotnet/tools/.store/dotnet-sonarscanner/6.2.0/dotnet-sonarscanner/6.2.0/tools/netcoreapp3.1/any/SonarQube.Analysis.xml

Following is the command I am running in pipeline:

    - dotnet sonarscanner begin \
      /o:org \
      /k:org_proj \
      dotnet sonarscanner end


The docs should help.