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.
/aspnet
flag? Also, do you see the same problem when running FxCop directly against the target assemblies (as opposed to via Sonarqube)? – Coke/aspnet
switch in this case? Is TestProject.dll an ASP.NET-generated assembly? Also, what does it reference? Are any of the references ASP.NET-generated assemblies? – Coke