Error in FxCop Phoenix analysis engine

人走茶凉 提交于 2020-01-01 11:45:20

问题


So I'm trying to run a bunch of rules which are defined in a RuleSet. The RuleSet file is actually generated using Sonarqube - I've selected absolutely all rules in there, including the FxCop, ReSharper and StyleCop rules. I'm kicking off FxCop like this:

C:/FxCop/FxCopCmd.exe /file:C:\TestProject\bin\TestProject.dll /ruleset:=C:\TestProject\testproject.ruleset /out:C:\TestProject\fxcop-report.xml /outxsl:none /forceoutput /searchgac /aspnet

It starts correctly, but I get the following message:

Initializing Introspection engine...
Analyzing...
Initializing Phoenix engine...
Analyzing...
Analysis Complete.
* 1 total analysis engine exceptions.

The XML output contains the following:

<Exception Keyword="CA0001" Kind="Engine">
    <Type>Phx.FatalError</Type>
    <ExceptionMessage>Exception of type 'Phx.FatalError' was thrown.</ExceptionMessage>
    <StackTrace>   at Phx.FatalError.Dispatch()
        at Phx.Logging.Diagnostics.DiagnosticMessage.LogMessage(Severity severity, DiagnosticInfo diagnosticInfo, SourceContext sourceContext, String descriptionString)
        at Phx.PE.PEUtilities.UserError(String infoMessage)
        at Phx.Pdb.ReaderImplementation.Open(Boolean loadTypeOnly)
        at Phx.PEModuleUnit.LoadPdb()
        at Phx.PE.ReaderPhase.CheckSymbolicInformation()
        at Phx.PEModuleUnit.LoadGlobalSymbols()
        at Phx.PEModuleUnit.LoadEncodedIRUnitList()
        at Phx.PEModuleUnit.GetEnumerableContributionUnit(ContributionUnitEnumerationKind contributionUnitEnumerationKind)
        at Phx.PEModuleUnit.GetEnumerableContributionUnit()
        at Microsoft.FxCop.Engines.Phoenix.PreScanPass.GetFunctionUnits(PEModuleUnit peModuleUnit)
        at Microsoft.FxCop.Engines.Phoenix.PreScanPass.Execute(ModuleUnit moduleUnit)
        at Phx.Passes.Pass.DoPass(ModuleUnit moduleUnit)
        at Phx.Passes.PassList.DoPassList(ModuleUnit moduleUnit)
        at Microsoft.FxCop.Engines.Phoenix.PhoenixAnalysisEngine.Host.ExecutePasses(PEModuleUnit peModuleUnit)
        at Microsoft.FxCop.Engines.Phoenix.PhoenixAnalysisEngine.AnalyzeInternal()
        at Microsoft.FxCop.Engines.Phoenix.PhoenixAnalysisEngine.Analyze()
        at Microsoft.FxCop.Common.EngineManager.Analyze(Project project, Boolean verboseOutput)
   </StackTrace>
  </Exception>

If I run the same command without the /aspnet flag I will still get the same error, but I do get the actual messages in the XML output file as well.

My end goal here is to run this from Sonarqube (using the Sonarqube runner in TeamCity), but I'm getting the exact same issues there as well. Starting the process from Teamcity I'm getting the following:

18:19:46][Step 4/4] INFO: ------------------------------------------------------------------------
[18:19:46][Step 4/4] INFO: EXECUTION FAILURE
[18:19:46][Step 4/4] INFO: ------------------------------------------------------------------------
[18:19:46][Step 4/4] Total time: 24.122s
[18:19:46][Step 4/4] ERROR: Error during Sonar runner execution
[18:19:46][Step 4/4] org.sonar.runner.impl.RunnerException: Unable to execute Sonar
[18:19:46][Step 4/4]    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
[18:19:46][Step 4/4]    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
[18:19:46][Step 4/4]    at java.security.AccessController.doPrivileged(Native Method)
[18:19:46][Step 4/4]    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
[18:19:46][Step 4/4]    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
[18:19:46][Step 4/4]    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
[18:19:46][Step 4/4]    at org.sonar.runner.api.Runner.execute(Runner.java:90)
[18:19:46][Step 4/4]    at org.sonar.runner.Main.executeTask(Main.java:70)
[18:19:46][Step 4/4]    at org.sonar.runner.Main.execute(Main.java:59)
[18:19:46][Step 4/4]    at org.sonar.runner.Main.main(Main.java:41)
[18:19:46][Step 4/4] Caused by: java.lang.IllegalStateException: The execution of "C:/FxCop/FxCopCmd.exe" failed and returned 1 as exit code. See http://msdn.microsoft.com/en-us/library/bb429400(v=vs.80).aspx for details.
[18:19:46][Step 4/4]    at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
[18:19:46][Step 4/4]    at org.sonar.plugins.fxcop.FxCopExecutor.execute(FxCopExecutor.java:63)
[18:19:46][Step 4/4]    at org.sonar.plugins.fxcop.FxCopSensor.analyse(FxCopSensor.java:102)
[18:19:46][Step 4/4]    at org.sonar.plugins.fxcop.FxCopSensor.analyse(FxCopSensor.java:87)
[18:19:46][Step 4/4]    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:59)
[18:19:46][Step 4/4]    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:51)
[18:19:46][Step 4/4]    at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:120)
[18:19:46][Step 4/4]    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
[18:19:46][Step 4/4]    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
[18:19:46][Step 4/4]    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
[18:19:46][Step 4/4]    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
[18:19:46][Step 4/4]    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
[18:19:46][Step 4/4]    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228)
[18:19:46][Step 4/4]    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
[18:19:46][Step 4/4] Final Memory: 20M/428M
[18:19:46][Step 4/4] INFO: ------------------------------------------------------------------------
[18:19:46][Step 4/4]    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
[18:19:46][Step 4/4]    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
[18:19:46][Step 4/4]    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
[18:19:46][Step 4/4]    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
[18:19:46][Step 4/4]    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
[18:19:46][Step 4/4]    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
[18:19:46][Step 4/4]    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
[18:19:46][Step 4/4]    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
[18:19:46][Step 4/4]    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
[18:19:46][Step 4/4]    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
[18:19:46][Step 4/4]    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45)
[18:19:46][Step 4/4]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[18:19:46][Step 4/4]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[18:19:46][Step 4/4]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[18:19:46][Step 4/4]    at java.lang.reflect.Method.invoke(Method.java:497)
[18:19:46][Step 4/4]    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
[18:19:46][Step 4/4]    ... 9 more
[18:19:46][Step 4/4] Process exited with code 1
[18:19:46][Step 4/4] Step SonarQube (SonarQube Runner) failed

This is using FxCop v12 installed on a box where there is no Visual Studio, in case that's of any importance...

Edit
The issue definitely is with the Phoenix analysis part - after disabling DFA rules described here it succeeds.


回答1:


Searching the Internet for the "Phx.FatalError" error, I found this blog post, in which the author basically says that doing a

regsrv32.exe msdia100.dll

(so apparently for VS2010 in his case), fixed the problem for him.

That lead me to the necessary hint what could have been the reason for the error on my machine.

I messed around on my DEV box with the Visual Studio Standalone Profiler setup [1]. I installed the profiling tools, that causes the contents of %ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Team Tools\Performance Tools (from the original VS installation) to be replaced, which I was not aware of at the time. However, said setup also creates (or replaces) the %ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\msdia120.dll file. That file is a COM server and is registered during setup (of Visual Studio or the Standalone Profiler package), which I also was not aware of.

Naturally, an uninstall of said Standalone Profiler package, uninstalls the files from the above directories and also unregisters msdia1xx.dll.

So, in my case the easiest fix was to reinstall in the Standalone Profiler package (x64 in my case) and everything worked again.

You might also be successful with just (re)registering your version of msdia1xx.dll [may need to be run as administrator]:

For Visual Studio 2010:

regsvr32 "%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\msdia100.dll"

For Visual Studio 2012:

regsvr32 "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\Packages\Debugger\msdia110.dll"

For Visual Studio 2013:

regsvr32 "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\msdia120.dll"

For Visual Studio 2015:

regsvr32 "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\Packages\Debugger\msdia140.dll"

[1] Located on your VS installation media under <drive>:\Standalone Profiler or in your VS installation directory %ProgramFiles(x86)%\Microsoft Visual Studio <version>\Team Tools\Performance Tools\Setup.



来源:https://stackoverflow.com/questions/30490358/error-in-fxcop-phoenix-analysis-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!