SonarLint's Exclude From Analysis does not work

  • I have installed SonarLint in Visual Studio 2017. (version 4.27.022695)
  • Enabled full solution anlysis.
  • SonarLint is connected to SonarQube Server (it has downloaded new rulesets from server)
  • Then i enabled Exclude from analyzing option on Test Projects
    • Right Click on Test Project ->SonarLint Connected Mode-> Exclude from Analysis
    • Which adds <SonarQubeExclude>True</SonarQubeExclude> into csproj
    • then i re-build the whole solution.

Issue
In visual studio i still see warnings from Test Project.

I have also tried setting the test project as SonarQube test project. So my csproj file has two entries now

<SonarQubeExclude>True</SonarQubeExclude>

<SonarQubeTestProject>True</SonarQubeTestProject>

However, upon building the solution in VS, I still see Sonar’s warnings and information from Test project

Hi @LP2020,

[Duplicate question on StackOverflow]

Unfortunately that setting is only used by the SonarScanner for MSBuild; it isn’t handled in the IDE.

There isn’t current any way to automatically exclude an entire project. [See below] There are a couple of tickets in the backlog that are related, namely #1337 and #1336.

Thanks. I will also update my SO post

1 Like

Update: if you’re using a recent version of Visual Studio 2019 you can control live analysis on a per-project basis using a built-in VS feature from the Property page for the project:

image

See the MS docs for more information.