nant - 如何将 nant 构建错误重定向到 'catch' 部分?

标签 nant

我需要在 nant 配置文件的“try-catch”部分构建我的应用程序,如下所示:

<trycatch>
        <try>
         <echo message="Start building MyApplication.."/>
         <call target="BuildApp"/>
        </try>
        <catch>
         <echo message="Build MyApp.sln is failed"/>
         <fail/>
        </catch>
</trycatch>

当构建失败时,它只显示消息:“Build MyApp.sln is failed”,没有任何失败原因的详细信息。如何将构建错误重定向到“catch”部分并查看失败的原因?

最佳答案

您需要添加property属性为catch标签:

<trycatch>
  <try>
    <echo message="Start building MyApplication.."/>
    <call target="BuildApp"/>
  </try>
  <catch property="failure.message">
    <echo message="Build MyApp.sln is failed"/>
    <echo message="Failure message: ${failure.message}"/>
    <fail />
  </catch>
</trycatch>

您也可以通过 <fail message="${failure.message}" /> 转发失败消息.

关于nant - 如何将 nant 构建错误重定向到 'catch' 部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13578870/

相关文章:

NAnt property::exists() 具有新定义的属性?

xml - 命名空间和特定的 xpath

Nant:按模式查找文件

通过 nant 运行时 Powershell 脚本失败

nant - 读取文本文件,分割文本文件中的行并使用 nant 脚本发送该行的电子邮件

.net - 在没有Visual Studio的情况下构建.net应用程序

.net - 在NAnt构建脚本中处理密码

continuous-integration - TeamCity Agent 的环境路径为 "lost"

nant - NAnt 是否有 if/then/else 任务?

visual-studio-2008 - 使用 nant 和 VS2008 构建平台代码