nant nantcontrib配置使用fxcop

时间:2010-03-25 14:09:16

标签: nant fxcop nantcontrib

我需要运行我在NAnt构建文件中实现的FxCop属性。 我有NAnt和NAntContrib。我已将nantcontrib\bin的内容复制到nant \ bin文件夹,并将环境变量设置为FxCopCmd.exe

然后我在运行NAnt脚本时遇到错误:

  

无效属性(fxcop)

可能是什么问题?

1 个答案:

答案 0 :(得分:1)

通过使用NAnt的exec任务,直接从NAnt调用FxCop,而不使用NAntContrib任务,这有​​点简单。有关实现的详细信息,请查看有关集成NAnt和FxCop的article I wrote

以下是代码:

<!-- specify location of required tools -->
<property name="dir.tools" value="tools" />

<!-- analyze build for code quality -->
<target name="analyze.fxcop" depends="build" description="Analyze generated code using FxCop"> 
    <!-- specify location of input and output files -->
    <property name="fxcop.input" value="wadmt.fxcop" />
    <property name="fxcop.output" value="${dir.build}fxcop-results.xml" /> 

    <!-- send the analysis work to the FxCop command-line tool -->
    <exec program="${dir.tools}fxcopFxCopCmd.exe" failonerror="false">
        <arg value="/project:${fxcop.input}" /> <!-- use the fxcop project file -->
        <arg value="/forceoutput" /> <!-- create output even if no violations are found -->
        <arg value="/summary" /> <!-- show some summary info -->
        <arg value="/out:${fxcop.output}" /> <!-- specify an output file -->
    </exec>
</target>