Disable source code analysis for .NET
Applies to: Visual Studio
Visual Studio for Mac
Visual Studio Code
This page helps you disable code analysis in Visual Studio. There are limitations to what you can disable, and the procedure for turning off code analysis differs depending on a few factors:
Project type (.NET Core/Standard versus .NET Framework)
.NET Core and .NET Standard projects have options on their Code Analysis properties page that let you turn off code analysis from analyzers installed as a NuGet package. For more information, see .NET Core and .NET Standard projects. To turn off source code analysis for .NET Framework projects, see .NET Framework projects.
Source analysis versus legacy analysis
This article applies to source code analysis and not to legacy (binary) analysis. For information about disabling legacy analysis, see How to: Enable and disable legacy code analysis.
.NET Core and .NET Standard projects
Starting in Visual Studio 2022 version 17.0.4, there are two checkboxes available in the Code Analysis properties page that let you control whether analyzers run at build time and design time. These options are project-specific.
To open this page, right-click the project node in Solution Explorer and select Properties. Select the Code Analysis tab.
- To disable source analysis at build time, uncheck the Run on build option.
- To disable live source analysis, uncheck the Run on live analysis option.
Note
Starting in Visual Studio 2022 version 17.0.4, if you prefer the on-demand code analysis execution workflow, you can disable analyzer execution during live analysis. Or build and manually trigger code analysis once on a project or a solution on demand. For information about running code analysis manually, see How to: Run Code Analysis Manually for Managed Code.
.NET Framework projects
To turn off source code analysis for analyzers, add one or more of the following MSBuild properties to the project file.
MSBuild property | Description | Default |
---|---|---|
RunAnalyzersDuringBuild |
Controls whether analyzers run at build time. | true |
RunAnalyzersDuringLiveAnalysis |
Controls whether analyzers analyze code live at design time. | true |
RunAnalyzers |
false disables analyzers at both build and design time. This property takes precedence over RunAnalyzersDuringBuild and RunAnalyzersDuringLiveAnalysis . |
true |
Examples:
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
<RunAnalyzers>false</RunAnalyzers>
This page helps you disable code analysis in Visual Studio. There are limitations to what you can disable, and the procedure for turning off code analysis differs depending on a few factors:
Project type (.NET Core/Standard versus .NET Framework)
.NET Core and .NET Standard projects have options on their Code Analysis properties page that let you turn off code analysis from analyzers installed as a NuGet package. For more information, see .NET Core and .NET Standard projects. To turn off source code analysis for .NET Framework projects, see .NET Framework projects.
Source analysis versus legacy analysis
This article applies to source code analysis and not to legacy (binary) analysis. For information about disabling legacy analysis, see How to: Enable and disable legacy code analysis.
.NET Core and .NET Standard projects
Starting in Visual Studio 2019 version 16.3, there are two checkboxes available in the Code Analysis properties page that let you control whether analyzers run at build time and design time. These options are project-specific.
To open this page, right-click the project node in Solution Explorer and select Properties. Select the Code Analysis tab.
- To disable source analysis at build time, uncheck the Run on build option.
- To disable live source analysis, uncheck the Run on live analysis option.
Note
Starting in Visual Studio 2019 version 16.5, if you prefer on-demand code analysis execution workflow, you can disable analyzer execution during live analysis or build and manually trigger code analysis once on a project or a solution on demand. For information about running code analysis manually, see How to: Run Code Analysis Manually for Managed Code.
.NET Framework projects
To turn off source code analysis for analyzers, add one or more of the following MSBuild properties to the project file.
MSBuild property | Description | Default |
---|---|---|
RunAnalyzersDuringBuild |
Controls whether analyzers run at build time. | true |
RunAnalyzersDuringLiveAnalysis |
Controls whether analyzers analyze code live at design time. | true |
RunAnalyzers |
Disables analyzers at both build and design time. This property takes precedence over RunAnalyzersDuringBuild and RunAnalyzersDuringLiveAnalysis . |
true |
Examples:
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
<RunAnalyzers>false</RunAnalyzers>
See also
Feedback
Submit and view feedback for