How to make Sonarqube exclude a .NET (C#) project from coverage measures

Summing up the above mentioned answers and also adding one point to it.

  1. To exclude a project from SonarQube Analysis from csproj we can achieve by adding the below code in .csproj of that project

    <PropertyGroup>
    <!-- Exclude the project from analysis -->
    <SonarQubeExclude>true</SonarQubeExclude>
    </PropertyGroup>
    
  2. To exclude a file from a project

     <ItemGroup>
     <SonarQubeSetting Include="sonar.coverage.exclusions">
     <Value>**/FileName.cs</Value>
     </SonarQubeSetting>
     </ItemGroup>
    
  3. And for multiple files

    <ItemGroup>
    <SonarQubeSetting Include="sonar.coverage.exclusions">
    <Value>**/FileName1.cs, **/FileName2.cs</Value>
    </SonarQubeSetting>
    </ItemGroup>
    

Also can refer this for regex patterns used

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)