【问题标题】:Nant does not launch nunit2 taskNant 不启动 nunit2 任务
【发布时间】:2012-06-27 11:34:36
【问题描述】:

我有一个非常简单的带有 Watin 测试的类,它是从 Visual Studio 构建和运行的。 现在我想用 Nant 构建它并启动它。我编写了以下 nant .build 文件:

<?xml version="1.0"?>
<project name="WatinTests" default="build">
  <property name="build.dir" value="c:WatinTests\bin\" />
  <property name="project.rootdirectory" value="." />
  <property name="solution.dir" value="."/>
  <property name="solution.file" value="${solution.dir}/WatinTests.csproj"/>
  <property name="build.configuration" value="debug" />
  <property name="nant.settings.currentframework" value="net-4.0" />
  <mkdir dir="${build.dir}" />
  <target name="build">
    <exec
      program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe"
      commandline="${solution.file} /t:Clean /p:Configuration=${build.configuration} /v:q"
      workingdir="."
      output="${build.dir}/WatinTests.dll" />
  </target>
  <target name="test" depends="build">
    <nunit2>
      <formatter type="Plain" />
      <test assemblyname="${build.dir}WatinTests.dll" />
    </nunit2>
  </target>
</project>

第一个任务成功执行 - WatinTests.dll 文件进入 \bin 目录。 但是测试没有启动。这是输出:

构建文件:file:///c:/WatinTests/nant.build 目标框架: 指定 Microsoft .NET Framework 4.0 目标:构建测试

构建:

测试:

构建失败

c:\WatinTests\nant.build(14,6):执行测试失败。如果你 程序集不是使用 NUnit 版本 2.6.0.12051 构建的,然后确保你 已重定向 ass embly 绑定。查阅文档 任务以获取更多信息。 无法加载文件或程序集“WatinTests.dll”或其依赖项之一。试图加载一个不正确的程序 格式。 无法加载文件或程序集“WatinTests.dll”或其依赖项之一。试图加载一个不正确的程序 格式。

这里有什么问题?

【问题讨论】:

标签: nunit nant


【解决方案1】:

Nant documentation 中所述,您是否将程序集绑定重定向添加到您的 app.config 中:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
      <bindingRedirect oldVersion="0.0.0.0-2.2.8.0" newVersion="2.2.8.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime> 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    相关资源
    最近更新 更多