我正在尝试通过Sonar-runner运行FxCopCmd 10.0。但是,即使FxCop生成分析报告,也会返回错误。由于返回错误,因此声纳运行器不会显示报告。
为了隔离该问题,我从提示符处运行了FxCopCmd。
返回的控制台错误消息是:
无论我运行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>
最佳答案
我通过删除目录%USERPROFILE%\ AppData \ Roaming \ Microsoft FxCop \ 1.32 \中的xml配置文件解决了此问题。
关于fxcop - FxCop初始化错误CA0001,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16363976/