理由は思い出せませんが、 <nunit2> タスクの使用をあきらめ、 <exec> タスクと nunit-console.exe を快適に使用しています。それが役立つ場合は、NUnit と FxCop を実行する私のテスト ターゲットを次に示します。実行可能ファイルが Windows パスにない場合はスキップされることに注意してください。
<target name="test" description="Run unit tests" depends="build">
<property name="windows-path" value="${string::to-lower(environment::get-variable('PATH'))}"/>
<property name="nunit-in-path"
value="${string::contains(windows-path, 'nunit')}"/>
<echo message="Tests skipped because no NUnit folder was found in the Windows path."
unless="${nunit-in-path}"/>
<exec program="nunit-console.exe" if="${nunit-in-path}">
<arg file="../MyProject/MyProjectTest.nunit"/>
</exec>
<property name="fxcop-in-path"
value="${string::contains(windows-path, 'fxcop')}"/>
<echo message="FxCop skipped because no FxCop folder was found in the Windows path."
unless="${fxcop-in-path}"/>
<fxcop projectFile="../MyProject/MyProject.fxcop" directOutputToConsole="true"
failOnAnalysisError="true" if="${fxcop-in-path}"/>
</target>