p97
(Charles Teague)
March 4, 2022, 5:45pm
#1
Template for a good new topic, formatted with Markdown :
ALM used - Azure DevOps
CI system used – Azure DevOps
Languages of the repository – C#
How do you add a file to our solution that will tell SonarCloud to skip files listed in it when determining code coverage?
p97
(Charles Teague)
March 8, 2022, 9:25pm
#3
Thank you. We successfully used #1 .
For #2 , it looks like this is for SonarQube instead of SonarCloud. Is it possible to use this approach with SonarCloud?
For #3 , We have a way to include and exclude projects.
1 Like
Colin
(Colin)
March 9, 2022, 9:30am
#4
Hey there.
What makes you say that? The documentation linked is for SonarCloud.
p97
(Charles Teague)
March 16, 2022, 3:21pm
#5
Thanks. Does /d:sonar.dotnet.exclude allow us to exclude files?
Here is what we tried by setting the following .props file that did not work:
<Project>
<!-- See https://docs.sonarqube.org/7.2/AnalysisParameters.html -->
<PropertyGroup>
<!-- Exclude current project from analysis-->
<!-- <SonarQubeExclude>true</SonarQubeExclude> -->
</PropertyGroup>
<!-- To exclude a file from from analysis -->
<ItemGroup>
<SonarQubeSetting Include="sonar.coverage.exclusions">
<Value>
Dir11\Dir12\Dir13\**,
Dir21\Dir22\**,
Dir31\Dir32\Dir33\**,
**\SomeName1*.cs,
**\*Somename2.cs
</Value>
</SonarQubeSetting>
</ItemGroup>
</Project>
p97
(Charles Teague)
March 16, 2022, 3:28pm
#6
a) We are looking for a way to have a single file with exclusions in our repository
b) Each exclusion should be on a separate line (if possible)
Colin
(Colin)
March 17, 2022, 12:56pm
#8
Hey there.
I’m not sure what sonar.dotnet.exclude
is referring to (sonar.coverage.exclusions
is the right parameter to use if you’re trying to ignore code coverage), I’m not sure where you found documentation for configuring a .props file this way.
If you’re looking to exclude files in a single place that isn’t the .csproj of affected projects or the SonarCloud UI – your best bet is to put them in your version-controlled azure-pipelines.yml file (where you can define additional properties that are passed to the scanner).