Sonarqube 必须设置sonar.cs.fxcop.assembly

Sonarqube 必须设置sonar.cs.fxcop.assembly,sonarqube,fxcop,Sonarqube,Fxcop,MSBuild SonarQube在QualityProfile中使用fxcop规则时引发问题“sonar.cs.fxcop.assembly必须设置”。请参见下面的例外情况 它与其他StyleCop和C#规则配合得很好。 我看过类似的帖子,但找不到解决办法 我正在使用: C:\Sonar\sonarqube-5.2 C:\Sonar\MSBuild.SonarQube.Runner-1.0.2 已安装以下插件: 插件C#4.3 插件样式COP 1.1 针对以下示例项目: C:\Sonar\s

MSBuild SonarQube在QualityProfile中使用fxcop规则时引发问题“sonar.cs.fxcop.assembly必须设置”。请参见下面的例外情况

它与其他StyleCop和C#规则配合得很好。 我看过类似的帖子,但找不到解决办法

我正在使用:

C:\Sonar\sonarqube-5.2
C:\Sonar\MSBuild.SonarQube.Runner-1.0.2
已安装以下插件: 插件C#4.3 插件样式COP 1.1

针对以下示例项目:

C:\Sonar\sonar-examples-master\projects\languages\csharp\ConsoleApplication1
我正在执行以下命令:

cd Sonar\MSBuild.SonarQube.Runner-1.0.2\

MSBuild.SonarQube.Runner.exe begin /k:"MyProjectKey" /n:"MyProjectName" /v:"MyProjectVersion"

"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" "C:\Sonar\sonar-examples-master\projects\languages\csharp\ConsoleApplication1\ConsoleApplication1.csproj" /t:Rebuild

MSBuild.SonarQube.Runner.exe end
我试图在.csproj文件中声明程序集位置,但没有成功。预期路径是什么样子的

<ItemGroup>
    <SonarQubeSetting Include="sonar.cs.fxcop.assembly">
        <Value>path to dll</Value>
    </SonarQubeSetting>
</ItemGroup>

默认情况下,通过在生成服务器上安装Visual Studio,
fxcopcmd.exe
存储在此处:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop

错误消息具有误导性:您不应该尝试设置
sonar.cs.fxcop.assembly
属性。可能发生的情况是,您正在未安装Visual Studio的计算机上运行分析,并且在
msbuild
本身期间(作为“代码分析”msbuild任务的一部分)没有触发FxCop


对于启用了FxCop规则但未安装FxCop的情况,即将推出的用于MSBuild版本1.1的SonarQube扫描程序已经包含了更好的错误消息。请参见

如果将fxcop程序集设置为指向应用程序dll,则问题将得到解决,如下所示

sonar.cs.fxcop.fxCopCmdPath=C:/ProgramFiles(x86)/Microsoft Visual Studio 12.0/Team Tools/Static Analysis Tools/fxcop/FxCopCmd.exe sonar.cs.fxcop.assembly=APPLICATIONNAME/bin/APPLICATIONNAME.dll


注意:请确保您提供了指向bin文件夹的正确路径。

我的计算机上安装了Visual Studio 2008、2010和2012,我可以在以下文件夹中找到FxCop:C:\Program Files(x86)\Microsoft Visual Studio 11.0\Team Tools\Static Analysis Tools\FxCop我是否需要安装另一版本的FxCop?因为我尚未安装VS2013,我已经安装了MS Build for VS2013我刚刚按照本文中描述的说明安装了FxCop 10,但我仍然发现了这个问题。是的,我怀疑您需要Visual Studio 2013才能顺利使用MSBuild 12。但是,您可以尝试将环境变量
%VisualStudioVersion%
设置为
11.0
,并查看这是否强制MSBuild 12查找Visual Studio 11安装。实际上,有一种更好的方法可以指定要使用的Visual Studio版本:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop