nant nantcontrib configuration to use fxcop

153 views Asked by At

I need to run FxCop attribute which I have implemented in NAnt build file. I have NAnt and NAntContrib. I have copied the contents of nantcontrib\bin to nant\bin folder and have set environment variable to FxCopCmd.exe.

Then I'm getting the error when I run NAnt script:

invalid attribute (fxcop)

What could be the problem?

1

There are 1 answers

0
Grant Palin On

It's a bit simpler to invoke FxCop directly from NAnt, without using the NAntContrib task, by using NAnt's exec task. For implementation details, have a look at an article I wrote about integrating NAnt and FxCop.

Here's the code:

<!-- 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>