VSIX - Set RunAnalyzers property in code
Using the following code, we are able to set the CodeAnalysisRuleSet XML node in a *.csproj file:
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.
Hi @Tom W ,
Was the thrown exception a
ArgumentExceptionexception? Besides, refer to this doc: RunAnalyzers, looks like the default value of
Sign in to comment
It was indeed an ArgumentException. The default value of RunAnalyzers is indeed true, but we want to set it to false in some cases.
Hi @Tom W , perhaps you can try to use this IVsBuildPropertyStorage2 interface.