Exclude folder from Analysis (.net/C#)

Hi there

We have an issue with build performance during sonarqube analysis on SonarQube Community Server. One project in our solution takes 33028.848 seconds to analyze while everything else seems to be fine. This results in our buildtime going from around 30mins to 2:45h.
As this specific project doesn’t need to be analyzed anyways, we want to exclude it completely from analysis.
We run our build on Teamcity. The whole folder is displayed in the log like this:
C:\Teamcity\SonarQubeBuildStep\Source\ProjectRootFolderToExclude\Project.ToExclude\SubfolderOfProject\File.cs

In ProjectSettings–>GeneralSettings–>AnalysisScope–>A. File Exclusions–>Source File Exclusions I tried following entries:
**/ProjectRootFolderToExclude/Project.ToExclude/**
**/ProjectRootFolderToExclude/Project.ToExclude/**/*
**/ProjectRootFolderToExclude/Project.ToExclude/**/*.cs
ProjectRootFolderToExclude/Project.ToExclude/**
ProjectRootFolderToExclude/Project.ToExclude/**/*
ProjectRootFolderToExclude/Project.ToExclude/**/*.cs

But none of them seem to do anything. The project is still reported to take over 30000 seconds. I also tried the same patterns to disable some rules in " Ignore Issues on Multiple Criteria" with the same result.

Can someone tell me what I’m doing wrong?

I tried to follow this: Narrowing the focus with analysis scope

If you need any more information, I’m happy to provide that.

All help is appreciated. Thanks

Edit:
One thing I saw is, that when I go to the issues list and filter for directories, the excluded directory is not shown.

Hi,

Most scanners apply exclusions by filtering out those files at the beginning and not analyzing them. SonarScanner for .NET applies exclusions by analyzing all the files and then filtering the results at the end. Instead, you want to exclude the project from analysis.

 
HTH,
Ann

Hi,

Thanks for the reply. I got to the same conclusion in the meantime.
Is there a way to do that a bit more granularly? Let’s say, I just wanna disable the analysis of certain rules for a certain project. Would that be possible?

Hi,

You want the rules to apply to some parts of your SonarQube Server project but not others? That’s an exclusion.

If you want them not applied at all, that’s a edit to your Quality Profile.

 
HTH,
Ann

Thanks for the answer

But isn’t a rule still run through the analyzer if I set an exclusion? It’s then just not analyzed in SonarQube.
I’m looking for something like <SonarQubeExclude>true</SonarQubeExclude> but for specific rules. Is that possible? That the sonarscanner completely ignores the rule for specfic projects/files

Hi,

With SonarScanner for .NET, yes, that’s the case.

Sorry, no.

 
Ann