Xamarin 和 SonarQube

Xamarin and SonarQube

我目前正在开发 Xamarin 移动应用程序并尝试使用 SonarQube 作为 CI 流程的一部分来加强代码质量。

有没有人有这方面的经验?

到目前为止,根据我的实验,我 运行 遇到了 Visual Studio 和 StyleCop 的 SonarLint 问题,我不知道这是否是因为项目是使用 xbuild 而不是 Visual Studio 或 MSBuild.

我看到的种类或错误是

Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

这似乎发生在 Visual Studio 的 SonarLint 被调用之后。

编辑:

14:59:19.350 INFO  - SonarLint for Visual Studio version 1.3.0.0
14:59:20.154 ERROR - 
14:59:20.337 ERROR - Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
14:59:20.338 ERROR -    at System.Collections.Immutable.ImmutableDictionary`2.get_Item(TKey key)
14:59:20.340 ERROR -    at SonarLint.Runner.Configuration.AddAnalyzerCommentRegularExpression(Builder builder)
14:59:20.341 ERROR -    at SonarLint.Runner.Configuration.Analyzers()
14:59:20.341 ERROR -    at SonarLint.Runner.Program.Main(String[] args)

用于 MSBuild 的 SonarQube 扫描器不支持 xbuild:如果您仍然尝试使用它,预计会遇到一些困难。

您使用的 SonarQube C# 插件版本似乎早于 4.4。可用的最新版本是 4.5 并删除了此代码的 AddAnalyzerCommentRegularExpression 部分,根据您的堆栈跟踪,该部分当前失败。

最终找到了问题的根源