FxCop 1.36 and importData service message

Hello All,

I've setup TeamCity and I must say it really looks beautiful for our project. I have one question though: We're running FxCop from our MSBuild script and are trying to publish the results in the build report. The Code Inspection tab appears, but its empty even though FxCop has generated results. The build log says the following:

[11:54:27]: Importing data from 'D:\TeamCity\buildAgent\work\de5f651e3cd65258\build\reports\fxcop-results.fxcop' with 'FxCop' processor
[11:54:27]: Won't handle tag ProjectOptions
[11:54:27]: Won't handle tag RuleFiles
[11:54:27]: Won't handle tag Groups
[11:54:27]: Won't handle tag Settings
[11:54:27]: Won't handle tag FxCopReport
[11:54:27]: Won't handle tag ProjectOptions
[11:54:27]: Won't handle tag RuleFiles
[11:54:27]: Won't handle tag Groups
[11:54:27]: Won't handle tag Settings
[11:54:27]: Won't handle tag FxCopReport


It seems as if it starts to import the results, but stops somewhere inside. We're using the FxCop task from the MSBuild Community Tasks:


  <Target Name="FxCop">

    <!-- Run FxCop and emit TeamCity progress messages -->
    <Message Text="##teamcity[progressStart 'Running FxCop...']"/>
    <FxCop
      ToolPath="$(FxCopPath)"
      TargetAssemblies="@(FxCopTargets)"
      RuleLibraries="@(FxCopRules)"
      AnalysisReportFileName="$(FxCopOutput)"
      DependencyDirectories="$(OutputDir)"
      FailOnError="False"
      />
    <Message Text="##teamcity[importData type='FxCop' path='$(FxCopOutput)']" />
    <Message Text="##teamcity[progressFinished 'FxCop completed.']"/>
   
    <!-- Transform the FxCop report to HTML -->
    <ItemGroup>
      <FxCopOutputs Include="$(FxCopOutput)" />
    </ItemGroup>
    <Xslt Inputs="@(FxCopOutputs)" Output="$(MSBuildProjectDirectory)\build\reports\fxcop-report.html" Xsl="$(FxCopPath)\Xml\FxCopReport.xsl" />

    <!-- Emit appropriate TeamCity status -->
    <XmlRead ContinueOnError="True" XmlFileName="$(FxCopOutput)" XPath="string(count(//Issue[@Level='CriticalError']))">
      <Output TaskParameter="Value" PropertyName="FxCopCriticalErrors" />
    </XmlRead>
    <XmlRead ContinueOnError="True" XmlFileName="$(FxCopOutput)" XPath="string(count(//Issue[@Level='Error']))">
      <Output TaskParameter="Value" PropertyName="FxCopErrors" />
    </XmlRead>
    <XmlRead ContinueOnError="True" XmlFileName="$(FxCopOutput)" XPath="string(count(//Issue[@Level='CriticalWarning']))">
      <Output TaskParameter="Value" PropertyName="FxCopCriticalWarnings" />
    </XmlRead>
    <XmlRead ContinueOnError="True" XmlFileName="$(FxCopOutput)" XPath="string(count(//Issue[@Level='Warning']))">
      <Output TaskParameter="Value" PropertyName="FxCopWarnings" />
    </XmlRead>
    <Math.Add Numbers="$(FxCopCriticalErrors);$(FxCopErrors);$(FxCopCriticalWarnings);$(FxCopWarnings)">
      <Output TaskParameter="Result" PropertyName="FxCopRuleViolations" />
    </Math.Add>
    <Message Text="##teamcity[buildStatus status='FAILURE' text='FxCop encountered $(FxCopRuleViolations) rule violation(s). Critical errors: $(FxCopCriticalErrors). Errors: $(FxCopErrors). Critical warnings: $(FxCopCriticalWarnings). Warnings: $(FxCopWarnings).']"  Condition="$(FxCopRuleViolations) &gt; 0" />

  </Target>


Any ideas?

Thanks!
Michael

1 comment
Comment actions Permalink

Ok, I've found the answer myself. If the AnalysisReportFileName attribute of the FxCop task is set to a file with an .fxcop extension, FxCop assumes it shall write its project file instead of a report file. I've changed the MSBuild script to save the report to an xml-file and works now.

0

Please sign in to leave a comment.