Configure .NET Core analysis with configuration file

I’m successfully analyzing a number of .NET Core applications written in C# with SonarCloud, using a combination of passing command-line parameters to dotnet-sonarscanner and setting some values via the Administration tab of SonarCloud. I wanted to make the configuration more transparent to all developers, so I want to move the settings out of Administration tab into the source code.

What is the best way to handle a large number of settings? In the past, I’ve used a file, but that now errors out with SonarScanner for .NET. I’ve seen references to SonarQube.Analysis.xml, but I think that’s only for server-level configuration, not project specific changes. There’s, but I believe that’s just for automatic analysis.

If possible, I’d rather have a configuration file with the key-value settings instead of a rather long command with lots of parameters being passed to dotnet-sonarscanner.

I appreciate any help that can be provided.

Hi @bo_flynn ,

Welcome to SonarSource Community! :sonarsource:

You have a noble goal of making the parameters more apparent in the logs, so I agree with your motivation. won’t work for .NET projects, so you can’t use that, just as you found out. There are pretty much only 2 ways to set project-level parameters for .NET:

  • via command line (or within the azure-pipeline.yaml for Azure DevOps, for example, which is like command line)
  • via .csproj file like so:
      <SonarQubeSetting Include="sonar.exclusions">

So if you use pipeline.yaml for Azure DevOps (or similar) or use .csproj file, you can version control your SonarCloud analysis parameters. Still not perfect but it’s a way to move the parameters out of the UI Administration tab.

There is no perfect solution for what you desire, so I’m going to feed your comments to our Product Managers so we have a record of this request.


That sounds great. I’ll test with putting my settings in a Directory.Build.props file and verify it’s picked up for all projects, then post back.

Thanks for the help,

1 Like