MsbuildSonar Runner +Fxcop - 没有 fxcop 问题发布到 server.SonarDashBoard 显示 0 技术债务
MsbuildSonar Runner +Fxcop - No fxcop issues are posted to server.SonarDashBoard shows 0 technical debt
我将 Sonarqube 5.1 与 MsBuildSonarRunner 一起用于我的 c#.net 项目分析。 Sonarqube 5.1 带有 C# 4.1 插件,最近我升级到 4.2。我已经使用 ONLY Fxcop 规则 创建了质量配置文件。我已经按照Sonar网站中提到的步骤进行了分析。
在分析中,我看到捕获了 FXcop 规则违规。但是当我浏览到 SonarDash 板时,它显示技术债务为 0,问题为 0。我已经多次检查我的步骤,我没有看到我这边有任何错误。问题未发布到服务器的原因可能是什么。
这是我的构建命令日志。我清楚地看到应用了 FXCOP 规则,并且在构建阶段在控制台上打印了违规行为。
===========================================================
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
FxCop 分析程序集,并依靠 *.pdb 文件将问题映射回源代码中的位置(即映射到特定行的特定 *.cs 文件)。
CA1823
报告的问题似乎与某个字段有关,由于 *.pdb 格式的限制,该问题未映射回源代码。在将 FxCop 结果导入 SonarQube 期间,这些问题将被忽略。您可以通过手动打开 FxCop 报告(您将在 .sonarqube\out*\ProjectInfo.xml.
中找到其路径来验证这一点
在 C# 插件的未来版本中已经有改进这一点的票证:https://jira.sonarsource.com/browse/SONARFXCOP-32
2015 年 11 月 18 日更新
经过对这个答案的多次评论(见下文),问题的根本原因终于找到了:SQL 服务器排序规则必须区分大小写 (CS) 和区分重音 (AS)。
如果不是这种情况,SonarQube 5.3 预计会更快失败,以避免这些奇怪的问题:https://jira.sonarsource.com/browse/SONAR-6884
我将 Sonarqube 5.1 与 MsBuildSonarRunner 一起用于我的 c#.net 项目分析。 Sonarqube 5.1 带有 C# 4.1 插件,最近我升级到 4.2。我已经使用 ONLY Fxcop 规则 创建了质量配置文件。我已经按照Sonar网站中提到的步骤进行了分析。
在分析中,我看到捕获了 FXcop 规则违规。但是当我浏览到 SonarDash 板时,它显示技术债务为 0,问题为 0。我已经多次检查我的步骤,我没有看到我这边有任何错误。问题未发布到服务器的原因可能是什么。
这是我的构建命令日志。我清楚地看到应用了 FXCOP 规则,并且在构建阶段在控制台上打印了违规行为。
===========================================================
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
FxCop 分析程序集,并依靠 *.pdb 文件将问题映射回源代码中的位置(即映射到特定行的特定 *.cs 文件)。
CA1823
报告的问题似乎与某个字段有关,由于 *.pdb 格式的限制,该问题未映射回源代码。在将 FxCop 结果导入 SonarQube 期间,这些问题将被忽略。您可以通过手动打开 FxCop 报告(您将在 .sonarqube\out*\ProjectInfo.xml.
在 C# 插件的未来版本中已经有改进这一点的票证:https://jira.sonarsource.com/browse/SONARFXCOP-32
2015 年 11 月 18 日更新
经过对这个答案的多次评论(见下文),问题的根本原因终于找到了:SQL 服务器排序规则必须区分大小写 (CS) 和区分重音 (AS)。
如果不是这种情况,SonarQube 5.3 预计会更快失败,以避免这些奇怪的问题:https://jira.sonarsource.com/browse/SONAR-6884