How to trace behavior of command line code analyzer

When you enable code analysis on build, the command line code analyzer (%APPDATA%\FxCop Integrator\CodeAnalysis.exe) will be used to analyze your project. This is a .NET console application, and uses TraceSource class to write trace logs. So, you can trace behavior of this tool with TraceListener classes.
  • Step 1
Create CodeAnalysis.exe.config in the %APPDATA%\FxCop Integrator folder.
  • Step 2
Add a trace source named "logger" and any trace listeners to the config file, as follows.
<?xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <system.diagnostics>
    <sources>
      <source name="logger" switchName="sourceSwitch" switchType="System.Diagnostics.SourceSwitch">
        <listeners>
          <add name="logFile"/>
        </listeners>
      </source>
    </sources>
    <switches>
      <add name="sourceSwitch" value="All"/>
    </switches>
    <sharedListeners>
      <add name="logFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\tmp\trace.txt"/>
    </sharedListeners>
  </system.diagnostics>
</configuration>
  • Step 3
Build your project again.

Last edited Nov 4, 2011 at 2:01 PM by sasaminn, version 3

Comments

No comments yet.