VSIX - Set RunAnalyzers property in code

Tom W 1 Reputation point

Using the following code, we are able to set the CodeAnalysisRuleSet XML node in a *.csproj file:

EnvDTE.Project project;
foreach (Configuration c in project.ConfigurationManager)
c.Properties.Item("CodeAnalysisRuleSet").Value = filename;

Now we would like to do the same for the "RunAnalyzers" property, but we get an exception when we try to set the property. Probably that property is not exposed through the EnvDTE.Project object.

c.Properties.Item("RunAnalyzers").Value = true;

Does somebody know the correct way to achieve this please? The intention is to be able to turn on and of code analysis from withing an extension.

Microsoft Build
Microsoft Build
A Microsoft platform for building applications with Visual Studio and .NET on Windows.
378 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
7,527 questions
{count} votes