2

我需要在 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>

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

4

1 回答 1

3

您需要将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}" />

于 2012-11-27T11:45:46.767 回答