Visual Studio Code Metrics PowerTool 10.0 View resutls in Team Ctiy

I am using Visual Studio Code Metrics Power Tool to find code metrics like CyclomaticComplexity,maintainabilityIndex and DepthOfInheritance . I would like to view the restuls produced by Code Metrics PowerTool in Team Ctiy. I used MSBuild to compile code and then run the code metrics analysis on the compiled output. Code Metrics Power Tool generated an XML output which looks like this :

 

<?xml version="1.0" encoding="utf-8"?>
<CodeMetricsReport Version="10.0">
<Targets>
<Target Name="E:\Projects\CI_Demo\CI_Demo\bin\Release\CI_Demo.dll">
<Modules>
<Module Name="CI_Demo.dll" AssemblyVersion="1.0.0.0" FileVersion="1.0.0.0">
<Metrics>
<Metric Name="MaintainabilityIndex" Value="90" />
<Metric Name="CyclomaticComplexity" Value="8" />
<Metric Name="ClassCoupling" Value="1" />
<Metric Name="DepthOfInheritance" Value="1" />
<Metric Name="LinesOfCode" Value="10" />
</Metrics>
.
.
.
.

</Module>
</Modules>
</Target>
</Targets>


Is there any way I read this xml by team city and display its results within it? I know Team City can be leveraged to view results produced by the static code analysis tool like FxCop. Can the same be done for Code Metrics PowerTool ?

3 comments
Comment actions Permalink

Hi

TeamCity does not import this type of reports automatically, so custom charts and service messages is the right way to go.
I've answered the question in your second thread.

0
Comment actions Permalink

Also you can vote for this feature request in TW-16949

0
Comment actions Permalink

The other thread appears to mean;
http://devnet.jetbrains.net/thread/312017

Sep 13, 2011 10:58 PM

Team City 6.5 Issue Using service message - TeamCityReportStatsValue to publish these values to TeamCity Server.
Hi,
I am new to TeamCity. I am setting up continuous integration process and running Code Metrics analysis step as part of this process. I am trying to calculate code metrics and display graphs (Customizing Statistics Charts) of this code metrics data over time.

In order to accomplish this task I have added a task in MSBuild to run Code Metrics analysis by running Metrics.exe. I have used the MSBuild community task XmlRead to extract the values from the xml output file generated by Metrices.exe and then the Team City task TeamCityReportStatsValue to publish these values to TeamCity Server.
However this step of publish these values to TeamCity Server is failing and the following is the error that is being logged:
[CodeMetrics] Unable to process service message: &quot;[buildStatisticValue key='maintainabilityIndex' value='90;90;90;95;98;95;98;79;77']&quot;
Following is the Code Metrics analysis Task from MSBuild.
  <Target Name="CodeMetrics" DependsOnTargets="Compile">
    <Exec Command='$(CodeMetricsTool) /plat:$(MSBuildToolsPath) /out:&quot;$(MSBuildProjectDirectory)\Reports\CodeMetricsReport.xml&quot;/f:&quot;$(MSBuildProjectDirectory)\CI_Demo\bin\Release\*.dll&quot;' />
    <XmlRead XPath="//*/Metric[@Name='MaintainabilityIndex']/@Value" XmlFileName="$(MSBuildProjectDirectory)\Reports\CodeMetricsReport.xml">
      <Output TaskParameter="Value" PropertyName="maintainabilityIndex" />
    </XmlRead>
    <TeamCityReportStatsValue Key="maintainabilityIndex" Value="$(maintainabilityIndex)" />

  </Target>
I would really appreciate any help resolving this issue.

Thanks.



Michael Kuzmin
1,204 posts since
Jul 30, 2005
Oct 18, 2011 3:43 PM   in response to: Salman Hasanuddin
Re: Team City 6.5 Issue Using service message - TeamCityReportStatsValue to publish these values to TeamCity Server.
Hi Salman

TeamCity expects a single integer value, but your xpath query returns an array.
Chose one of the metric instancer you want to display, or publish them as separate keys with different names.

0

Please sign in to leave a comment.