我正在尝试通过 Sonar-runner 运行 FxCopCmd 10.0。但是,即使 FxCop 生成分析报告,它也会返回错误。因为它返回一个错误,所以 sonar-runner 不会吞下报告。
为了隔离问题,我从提示符中运行了 FxCopCmd。
返回的控制台错误消息是:
- FxCop 初始化期间发生错误:
- 设置文件中的“规则”目录格式错误或不存在。
无论我运行 FxCop 10.0 还是 1.36,我都会遇到同样的错误。如果我使用 FxCop Gui 创建一个全新的空项目,然后打开它,Gui 会报告相同的错误消息,但会显示所有规则。
日志显示 FxCop 完成分析并输出 78 条消息。该报告包含 78 条消息。它似乎也找到了规律。
我不知道接下来要检查什么。
发出的命令
C:\svn\system-sr\tools\fxcop-10.0\FxCopCmd.exe /p:C:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\.sonar\sonar.FxCop /out:C:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\.sonar\fxcop-report.xml /f:C:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\bin\com.me.mySystem.dll /igc /to:600 /gac /v > verbose.log
详细日志结束
Cleaning Up Rules...
Analysis Complete.
Writing 78 messages...
Writing report to C:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\.sonar\fxcop-report.xml...
Done:00:00:02.5852585
FxCop 报告的部分内容(完整报告包含 78 条消息,如日志所示)
<!-- snipped -->
<Member Name="#MaintainStrataSelection()" Kind="Method" Static="False" Accessibility="Private" ExternallyVisible="False">
<Messages>
<Message Id="System.Int32.Parse(System.String)" TypeName="SpecifyIFormatProvider" Category="Microsoft.Globalization" CheckId="CA1305" Status="Active" Created="2013-05-03 15:45:07Z" FixCategory="NonBreaking">
<Issue Name="IFormatProviderAlternate" Certainty="95" Level="Error" Path="c:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\UserControl" File="ConfirmSubmitUserControl.ascx.cs" Line="388">Because the behavior of 'int.Parse(string)' could vary based on the current user's locale settings, replace this call in 'ConfirmSubmitUserControl.MaintainStrataSelection()' with a call to 'int.Parse(string, IFormatProvider)'. If the result of 'int.Parse(string, IFormatProvider)' will be based on input from the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will based on input stored and accessed by software, such as when it is loaded from disk or from a database, specify 'CultureInfo.InvariantCulture'.</Issue>
</Message>
</Messages>
</Member>
<Member Name="#Page_PreRender(System.Object,System.EventArgs)" Kind="Method" Static="False" Accessibility="Family" ExternallyVisible="True">
<Messages>
<Message Id="System.Int32.Parse(System.String)" TypeName="SpecifyIFormatProvider" Category="Microsoft.Globalization" CheckId="CA1305" Status="Active" Created="2013-05-03 15:45:07Z" FixCategory="NonBreaking">
<Issue Name="IFormatProviderAlternate" Certainty="95" Level="Error" Path="c:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\UserControl" File="ConfirmSubmitUserControl.ascx.cs" Line="105">Because the behavior of 'int.Parse(string)' could vary based on the current user's locale settings, replace this call in 'ConfirmSubmitUserControl.Page_PreRender(object, EventArgs)' with a call to 'int.Parse(string, IFormatProvider)'. If the result of 'int.Parse(string, IFormatProvider)' will be based on input from the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will based on input stored and accessed by software, such as when it is loaded from disk or from a database, specify 'CultureInfo.InvariantCulture'.</Issue>
</Message>
</Messages>
</Member>
<Member Name="#UpdatePageSelectedItems()" Kind="Method" Static="False" Accessibility="Private" ExternallyVisible="False">
<Messages>
<Message Id="System.Int32.ToString" TypeName="SpecifyIFormatProvider" Category="Microsoft.Globalization" CheckId="CA1305" Status="Active" Created="2013-05-03 15:45:07Z" FixCategory="NonBreaking">
<Issue Name="IFormatProviderAlternateString" Certainty="95" Level="Error" Path="c:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\UserControl" File="ConfirmSubmitUserControl.ascx.cs" Line="507">Because the behavior of 'int.ToString()' could vary based on the current user's locale settings, replace this call in 'ConfirmSubmitUserControl.UpdatePageSelectedItems()' with a call to 'int.ToString(IFormatProvider)'. If the result of 'int.ToString(IFormatProvider)' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.</Issue>
<Issue Name="IFormatProviderAlternateString" Certainty="95" Level="Error" Path="c:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\UserControl" File="ConfirmSubmitUserControl.ascx.cs" Line="512">Because the behavior of 'int.ToString()' could vary based on the current user's locale settings, replace this call in 'ConfirmSubmitUserControl.UpdatePageSelectedItems()' with a call to 'int.ToString(IFormatProvider)'. If the result of 'int.ToString(IFormatProvider)' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
</Types>
</Namespace>
</Namespaces>
</Module>
</Modules>
</Target>
</Targets>
<Rules>
<!-- snipped -->
</Rules>
<Localized>
<!-- snipped -->
</Localized>
<DebugInfo>
<!-- snipped -->
</SearchPaths>
<ResolvedAssemblies>
<!-- snipped -->
</ResolvedAssemblies>
</DebugInfo>
<Exceptions>
<Exception Keyword="CA0001" Kind="Initialization">
<Type>Microsoft.FxCop.Sdk.FxCopException</Type>
<ExceptionMessage>'Rules' directory in settings file has bad format or does not exist.</ExceptionMessage>
</Exception>
</Exceptions>
</FxCopReport>