Install Free
Visual Studio | Using SonarLint | File exclusions

File exclusions

On this page

All versions of SonarLint will fetch file exclusions from the SonarQube or SonarCloud server when you bind a project or update a binding while running in Connected Mode. Check the SonarQube and SonarCloud documentation for information about defining your Analysis scope.

File exclusions in the IDE

Defining file exclusions locally in SonarLint for Visual Studio is not yet possible, however, SonarLint will fetch file exclusions from the SonarQube or SonarCloud server when you bind a project or update a binding. See below for more information.

Retrieving exclusions from the server

File exclusions

Defining file exclusions locally in SonarLint for Visual Studio is not yet possible, however, SonarLint will fetch file exclusions from the SonarQube or SonarCloud server when you bind a project or update a binding. These settings are saved to a file named sonar.settings.json. 

Note that in SonarLint for Visual Studio 7.0, the settings file was moved outside of the solution directory; please check the Legacy Connected Mode article on the Previous versions page for information about the settings file in versions 6.16 and older.

For more information about how the SonarLint settings are handled by the server, see the SonarQube or SonarCloud documentation on setting your analysis scope.

File exclusions must be defined on the SonarQube or SonarCloud server.

Known limitations for file exclusions:

  • Supported Languages: C# & VB (.NET support in SonarLint v6.15+), C, C++, CSS, JavaScript, TypeScript, and Secrets.
  • Patterns should start with **/
  • Multicriteria and Test exclusions are not supported. SonarLint for Visual Studio only supports Global Source File Exclusions, Source File Exclusions, and Source File Inclusions when setting the analysis scope. See the pages about file inclusion and exclusion on SonarQube and SonarCloud in their documentation.

Managing exclusions in previous versions

In SonarLint for Visual Studio 6.16 and earlier, the sonar.settings.json file which saves the server defined file exclusions lives in the local .sonarlint folder. 

You must manually Update your binding to refresh the sonar.setting.json file when changes are made in SonarQube or SonarCloud; go Team Explorer > SonarQube, right-click the project whose binding you want to update, and select Update:

Right-click on your project to Update the binding.



Was this page helpful?

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARQUBE, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License