Il est un peu plus simple d'appeler FxCop directement à partir de NAnt, sans utiliser la tâche NAntContrib, en utilisant la tâche exec
de NAnt. Pour les détails de mise en œuvre, jetez un oeil à un article I wrote sur l'intégration de NAnt et FxCop.
Voici le 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>