我希望自动化在.NET解决方案上收集代码指标的过程。有没有办法让msbuild运行VS2008开发版中包含的Code Metrics功能?
我最终可能会使用SourceMonitor,但我想知道是否有办法从命令行使用VS代码指标引擎。
答案 0 :(得分:9)
最后,Microsoft使用新的“a way to automate the Visual Studio code metrics feature”向我们提供了power tool。
答案 1 :(得分:5)
这就是我公司使用MSBuild自动化FxCop的方式:
<!-- The directory where FxCop is installed. -->
<FxCopDirectory>C:\Program Files\Microsoft FxCop 1.36</FxCopDirectory>
<!-- The FxCop console executable.. -->
<FxCopCmd>$(FxCopDirectory)\FxCopCmd</FxCopCmd>
<Target Name="CodeAnalysis>
<!-- Once to get XML for metrics. -->
<Exec Command=""$(FxCopCmd)" /p:"$(BuildDirectory)\FxCop\RuleSet.FxCop" /out:$(BuildResults)\FxCop.xml /summary /verbose /f:$(Binaries)\@(CodeAnalysis, ' /f:$(Binaries)\')" />
<!-- Once to report with the build results. -->
<Exec Command=""$(FxCopCmd)" /p:"$(BuildDirectory)\FxCop\RuleSet.FxCop" /out:$(BuildResults)\FxCop.html /summary /verbose /applyoutXsl:$(MSBuildTasks)\CodeAnalysisReport.xsl /f:$(Binaries)\@(CodeAnalysis, ' /f:$(Binaries)\')" />
<!-- Update the FxCop report so that it is fully expanded by default. -->
<FileUpdate Regex="<body\s"
ReplacementText="<body onLoad="ExpandAll();" "
Files="$(BuildResults)\FxCop.html" />
</Target>
<!-- The directory where FxCop is installed. -->
<FxCopDirectory>C:\Program Files\Microsoft FxCop 1.36</FxCopDirectory>
<!-- The FxCop console executable.. -->
<FxCopCmd>$(FxCopDirectory)\FxCopCmd</FxCopCmd>
<Target Name="CodeAnalysis>
<!-- Once to get XML for metrics. -->
<Exec Command=""$(FxCopCmd)" /p:"$(BuildDirectory)\FxCop\RuleSet.FxCop" /out:$(BuildResults)\FxCop.xml /summary /verbose /f:$(Binaries)\@(CodeAnalysis, ' /f:$(Binaries)\')" />
<!-- Once to report with the build results. -->
<Exec Command=""$(FxCopCmd)" /p:"$(BuildDirectory)\FxCop\RuleSet.FxCop" /out:$(BuildResults)\FxCop.html /summary /verbose /applyoutXsl:$(MSBuildTasks)\CodeAnalysisReport.xsl /f:$(Binaries)\@(CodeAnalysis, ' /f:$(Binaries)\')" />
<!-- Update the FxCop report so that it is fully expanded by default. -->
<FileUpdate Regex="<body\s"
ReplacementText="<body onLoad="ExpandAll();" "
Files="$(BuildResults)\FxCop.html" />
</Target>
然后,您可以编写一些C#代码来使用输出文件:
答案 2 :(得分:2)