首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MsbuildSonar运行程序+Fxcop -没有fxcop问题被发布到server.SonarDashBoard显示0技术债务

MsbuildSonar运行程序+Fxcop -没有fxcop问题被发布到server.SonarDashBoard显示0技术债务
EN

Stack Overflow用户
提问于 2015-10-20 14:52:09
回答 1查看 424关注 0票数 0

我使用Sonarqube5.1和MsBuildSonarRunner进行c#.net项目分析。Sonarqube5.1附带了C# 4.1插件,最近我升级到4.2。我只使用创建了一个质量配置文件,只使用Fxcop 。我遵循了Sonar站点中提到的步骤进行分析。

在分析中,我发现FXcop规则违规是被捕获的。但是当我浏览SonarDash板时,它显示技术债务为0,问题为0。我已经复习了很多次了,我没有看到我身边有任何错误。为什么没有将问题发布到服务器上?

这是我的构建命令日志。我清楚地看到,在构建阶段,FXCOP规则被应用并且违规被打印在控制台上。

代码语言:javascript
复制
===========================================================

 Microsoft (R) Build Engine version 12.0.21005.1
[Microsoft .NET Framework, version 4.0.30319.34209]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 10/19/2015 12:20:14 PM.
Project "D:\Sqp\Polindrome\Polindrome\Polindrome.csproj" on node 1 (default targets).

GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.

CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.

_CopyAppConfigFile:
Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.

CopyFilesToOutputDirectory:
  Polindrome -> D:\Sqp\Polindrome\Polindrome\bin\Debug\Polindrome.exe

OverrideCodeAnalysisProperties:
  Running FxCop analysis using the SonarQube ruleset. Ruleset: D:\Sqp\Polindrome\Polindrome\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset

RunCodeAnalysis:
  Running Code Analysis...
  C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe  /outputCulture:1033 /out:"bin\Debug\Polindrome.exe.CodeAnalysisLog.xml" /file:"bin\Debug\Polindrome.exe" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Xml.Linq.dll" /directory:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1" /ruleSet:"=D:\Sqp\Polindrome\Polindrome\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset" /rulesetdirectory:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\\Rule Sets" /rule:"-C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\\Rules" /searchgac /ignoreinvalidtargets /forceoutput /successfile /ignoregeneratedcode /saveMessagesToReport:Active /timeout:120 


MSBUILD : **warning CA1823: Microsoft.Performance : It appears that field 'Program.AccountList' is never used or is only ever assigned to. Use this field or remove it.** [D:\Sqp\Polindrome\Polindrome\Polindrome.csproj]

Code Analysis Complete -- 0 error(s), 1 warning(s)
SetStyleCopAnalysisSettings:
Setting 'sonar.stylecop.projectFilePath' to 'D:\Sqp\Polindrome\Polindrome\Polindrome.csproj'

WriteSonarQubeProjectData:
  Directory "D:\Sqp\Polindrome\Polindrome\.sonarqube\out\\Polindrome__AnyCPU_Debug_635803356164104589" doesn't exist. Skipping.
  Creating directory "D:\Sqp\Polindrome\Polindrome\.sonarqube\out\\Polindrome__AnyCPU_Debug_635803356164104589".
Done Building Project "D:\Sqp\Polindrome\Polindrome\Polindrome.csproj" (default targets).

Build succeeded.

"D:\Sqp\Polindrome\Polindrome\Polindrome.csproj" (default target) (1) ->
(RunCodeAnalysis target) -> 
  MSBUILD : warning CA1823: Microsoft.Performance : It appears that field 'Program.AccountList' is never used or is only ever assigned to. Use this field or remove it. [D:\Sqp\Polindrome\Polindrome\Polindrome.csproj]

    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.82
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-21 09:10:16

FxCop分析程序集,并依赖于*.pdb文件将问题映射回源代码中的位置(即特定行的特定*.cs文件)。

CA1823报告的问题似乎出现在一个字段上,由于*.pdb格式的限制,该字段没有映射回源代码。在将FxCop结果导入SonarQube期间,这些问题将被忽略。您可以通过手动打开FxCop报告(您可以在.sonarqube\out*\ProjectInfo.xml中找到它的路径)来验证这一点。

在C#插件的未来版本:https://jira.sonarsource.com/browse/SONARFXCOP-32中,已经有了一张改进这一特性的票证。

更新2015年11月18日

在对这个答案进行了多次评论之后(参见下面),问题的根源终于找到了: Server排序规则必须区分大小写(CS)和重音敏感(AS)。

如果情况并非如此,预计SonarQube 5.3会更快地失败,以避免这些奇怪的问题:https://jira.sonarsource.com/browse/SONAR-6884

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33239912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档