CA0064 : No analysis was performed

Getting the error - ‘|Warning|CA0064 : No analysis was performed because the specified rule set could not be loaded or did not contain any managed code analysis rules.’

IDE: Visual Studio 2017 Professional
Version of Sonar Qube: 7.7
SonarLint: (Connected mode)

My SonarLInt is connecting to SonarQube and I am able to bind the rules. I can see the rule set also downloaded into the solution.

Later, I created custom rules using Roslyn SDK and added it to SonarQube. The Custom rules can also be seen on the Server.

But when i try to run Analyzer from Visual studio it is throwing the CA0064 error - ‘No analysis was performed because the specified rule set could not be loaded or did not contain any managed code analysis rules’

Hi. How are you triggering the analysis - from the Analyze, Run Code Analysis... menu?

Try opening the ruleset in Visual Studio and check the rules that are enabled. VS will refuse to open the ruleset if it is invalid (i.e. the first of the possible problems listed in the warning).

If the ruleset opens in VS, check the rules that are enabled. For example, the following configuration will cause the CA0064 warning because none of the selected rules are “managed” rules (I’m guessing that means the selected rules are legacy FxCop rules):


I am also experiencing this problem. A handful of additional details:

  • I Have multiple C# projects within the solution. I have the same checkout in two locations, in the first one it only runs analysis on the first project. On the others, all the projects report the CA0064 message.

  • I have tried various methods of running the analysis: Analyze -> Run Code Analysis from the top menu and the project menus, both on the individual projects and the individual solutions. The results are consistent not matter how I run them.

  • I was able to open the ruleset, verified various rules were active.

  • Also running in connected mode, which appears to connect appropriately.

Version information:

  • Microsoft Visual Studio Professional 2017, Version 15.9.12
  • SonarLint for Visual Studio,
  • Windows 10
  • SonarQube Server Version 7.7

See this SonarLint issue for an explanation of this rather unfortunate and confusing behaviour.

To summarise, this is down to how VS/MSBuild works. Roslyn rules installed in a VSIX are only run in the background in the IDE. If you want the rules to also be run in standalone MSBuilds, you would need to install the analyzer NuGet packages into each project you wanted to analyze.
Selecting Run code analysis in VS actually runs a build, so it’s effectively the same as running MSBuild with /p:RunCodeAnalysis=true