How do I disable all Roslyn Code Analyzers?
Solution 1
Try Tools/Options/Text Editor/C#/Advanced
and disable full solution analysis. It's only available since VS2015 Update 2.
Solution 2
You can disable analyzers on a per-project basis.
To do it, right click on Project>References>Analyzers in the Solution Explorer and hit Open Active Rule Set
You can disable individual analyzers or entire bundles of analyzers.
This creates a <ProjectName>.ruleset
file and modifies the <ProjectName>.csproj
, which means that you will share this configuration with your team unless you exclude these changes from source control.
Note: Changes are applied after you close and re-open the solution.
Changes to the .csproj
:
<Project ...>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<CodeAnalysisRuleSet>Example.ruleset</CodeAnalysisRuleSet>
Example.ruleset
file:
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for WpfApplication1" Description="Code analysis rules for WpfApplication1.csproj." ToolsVersion="14.0">
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
<Rule Id="AD0001" Action="None" />
<Rule Id="CS0028" Action="None" />
...
Solution 3
Disable below setting in Tools/Options/Text Editor/C#/Advanced and disable use 64-bit process for code analysis under analysis group. it was tested in vs2019.
Solution 4
Try a combo of the following in your csproj or Directory.Build.props files
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
<RunAnalyzers>false</RunAnalyzers>
Solution 5
It is possible to reference a ruleset file located in the parent folder
<Project ...>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<CodeAnalysisRuleSet>..\Example.ruleset</CodeAnalysisRuleSet>
This way you could define one ruleset for the entire solution.
Comments
-
JoshVarty almost 3 years
I'm trying to work with a large opensource project that has a handful of Roslyn Code Analyzers. When I open the solution Visual Studio uses ~35% CPU for about 15 minutes. Using PerfView I've figured out that the code analyzers being run on the solution are bogging down Visual Studio.
I know it's possible to disable analyzers on a per-project basis but this solution contains over 100 projects so I'd rather not do this one-by-one.
My question(s):
- Can I disable all Roslyn Analyzers for a given solution to avoid this?
- Can I disable all Roslyn Analyzers for all solutions in Visual Studio?
-
JoshVarty about 8 yearsThe issue here is that there are hundreds of projects in the solution so I was hoping I wouldn't have to disable them one-by-one. They're also under source control I don't control, so when I pull I believe my changes will be overwritten, right?
-
Amadeusz Wieczorek about 8 yearsI hope there's a way to manage analyzers on a scale of the entire solution. Maybe someone will pitch in.
-
Amadeusz Wieczorek about 8 yearsTo go around the source control issues, create a default
.ruleset
file (so that.csproj
is updated) and commit these changes. Then, apply your configuration and follow this guide to keep changes out of git repo -
Maxim almost 8 years@JoshVarty, I have installed Update 2 but nothing is available there.
-
Tamas almost 8 yearsIt's a checkbox in the Editor Helper group.
-
HappyNomad almost 7 years@rolls It does work. Read here to understand what the checkbox is for.
-
rollsch almost 7 yearsYes but the service is still present and using CPU. So what does that mean?
-
S.Serpooshan over 6 yearsmy firewall pops up and shows that
RoslynCodeAnalysisService32
is trying to connect to internet, even whenfull solution analysis
is not checked! -
rollsch over 5 yearsThis doesn't actually stop the CPU usage though.
-
rollsch over 5 yearsThis doesn't actually stop the CPU usage though.
-
Christian Findlay about 5 yearsThis doesn't work with the new Roslyn Analysers NuGet package