Summing up the above mentioned answers and also adding one point to it.
-
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>
-
To exclude a file from a project
<ItemGroup> <SonarQubeSetting Include="sonar.coverage.exclusions"> <Value>**/FileName.cs</Value> </SonarQubeSetting> </ItemGroup>
-
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