How to configure sonar issue as warning instead of error


I have installed sonar lint on my visual studio 2015. I have connected to our sonar qube server and bonded solution successfully with local solution.

Suppose this solution contains 2 projects. project1 and project2.

Now for Project1, I am getting" S103 - Lines should not be too long" as a warning.
but for Project2, I am getting “S103 -Lines should not be too long” as an error which results in Build Failure.

Why this behavior is different across projects in same solution. How can I change this behavior?


Hi @ganeshmate333,

Could you have a look and see if your projects contain ruleset files? Ruleset are the classical way to turn on or off a rule and change its severity.


No I don’t want to turn off any rule. Even these issues are existing and having low or normal severity., but due to my project build settings these low severity warnings are also getting considered as error. I know this is default behavior but Can I change this behavior only for sonar issues. I want these warning should show as per their severity configured in rule and not as per build configuration.

I have configured “Treat warning as error” in my project settings which I don’t want to change.

Project->Right click properties -> Build -> Treat warning as error -> All

Now our project is very old and I have configured sonar lint recently which (sonar analyzer) gives lots of existing issues(warnings).

Now due to my project settings all my existing sonar warnings are getting considered as error due to which I am not able to build project.

So my question is, Is there any way to exclude sonar warnings from this configuration (treat warning as error) and I don’t want to change my project settings.

Hi Ganesh,

Your question is actually not really related to our product but more of a general msbuild configuration question. On this stackoverflow page you will find 2 ways (one which requires modifying your projects and the other the build command line arguments)


Hi, this is exactly the point, I am facing this situation as well. I want to get compilation warnings as errors and SonarQube warnings as warnings because these are just advisory warnings … not substantial for us. If these cannot be solved it is really issue for our team …

Hi @Ivo_Kovacka. Welcome to the community.

Apologies for the delay in replying - somehow I missed your post until now.

To make sure I understand you correctly, you have “Treat warnings as errors” set for your projects, but you want want only some warnings to be treated as errors and not others? That isn’t how “Treat warnings as errors” works - it applies to all warnings.

As Amaury said in his answers, your question is really about the standard behaviour of VS/MSBuild, and rulesets are the classical way to turn on or off a rule and change its severity.

Either turn off “Treat warnings as errors” and create a ruleset that changes the severity of the compiler warnings you care about to “error”, or leave “Treat warnings as errors” on and create a ruleset that changes the severity of all warnings you don’t want to be treated as errors to a lower level severity.