NANT 构建错误:Cmd

发布于 2024-12-01 04:49:38 字数 356 浏览 1 评论 0原文

我正在尝试执行 NAnt 构建脚本,该脚本在一个环境中完美工作,但最近我已将构建文件迁移到一台新机器,我在其中面临以下问题。

使用的 NAnt 代码: exec program="cmd" commandline="/c ${build.dir}\XXX.vbs ${build.version}" failureonerror="false"

NAne 收到错误 外部程序失败:cmd(返回代码为 1)

我的可能尝试克服此问题 我检查了环境变量,发现一切都很好,并且与旧机器进行了比较,匹配相同。

有什么解决方案/评论吗?

I am trying to execute a NAnt build script, which is perfectly working in one environment, but recently I have migrated my Build files to a new machine where I am facing the below issue.

NAnt Code Used :
exec program="cmd" commandline="/c ${build.dir}\XXX.vbs ${build.version}" failonerror="false"

NAne Error received
External Program Failed: cmd (return code was 1)

My Possible tries to overcome this
I have checked the environment variables and found that all are fine and also compared with the old machine to match the same.

Any solutions / comments ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情域 2024-12-08 04:49:38

看来“cmd”正在运行,您不需要提供完整路径。错误“外部程序失败:cmd(返回代码为 1)”表示“cmd”已运行,但产生了错误。换句话说,您的 VB 脚本(即“XXX.vbs”)失败了。请尝试以下操作来查找实际错误:

  1. 验证“${build.dir}\XXX.vbs”的扩展值是否是有效的文件/位置。如果您使用的是相对路径,请仔细检查您的工作目录。

    
    

    
    
  2. 从命令行运行 NAnt 脚本。这将为您提供更好的错误消息,例如来自 Windows Script Host 的弹出错误消息。

    C:\YourTools\NAnt.exe -buildfile:MyBuildScript.build
    

    避免命令窗口,重定向程序的输出。将“>> exec.log”附加到“exec”任务中的命令行字符串,然后检查输出/日志文件的内容(即“exec.log”)。

     ;
    
  3. 或者,使用“exec”任务的更好方法是使用嵌套的“arg”元素。如果你的论点中有空格,这会有所帮助;你的脚本会读起来更清晰:

    
        
        >
        
    
    
  4. 最后,如果您的 VB 脚本由于无效参数(可能是因为“${build.version}”中的空格)而失败,请使用如下所示的内容来调试 VB 脚本:

    WScript.echo "参数计数", wscript.arguments.count
    
    对于 i = 0 到 wscript.arguments.count - 1
        Wscript.Echo wscript.arguments.item(i)
    下一个
    

:这有帮助。

It seems "cmd" is running and you don't need to provide the full path. The error "External Program Failed: cmd (return code was 1)" means the 'cmd' ran but it produced an error. In other words your VB script (i.e. 'XXX.vbs') is failing. Try the following to find the actual error:

  1. Validate that the expanded value of "${build.dir}\XXX.vbs" is a valid file/location. Double check your working directory if you're working with relative paths.

    <echo message="${build.dir}\XXX.vbs" />
    

    or

    <echo message="${file::exists(build.dir + '\XXX.vbs')}" />
    
  2. Run your NAnt script from the command line. This will give you a better error message, like a popup error from Windows Script Host.

    C:\YourTools\NAnt.exe -buildfile:MyBuildScript.build
    

    Avoid the command window, redirect the program's output. Append " >> exec.log" to your commandline string in the 'exec' task, then check the contents of the output/log file (i.e. 'exec.log').

    <exec program="cmd" commandline="/c ${build.dir}\XXX.vbs ${build.version} >> xxx_exec.log" failonerror="false" />
    
  3. Alternatively, a better way to use the 'exec' task is to use nested 'arg' elements. This would help in the case that your arguments have spaces in them; and your script will read clearer:

    <exec program="cmd" failonerror="false">
        <arg value="/c" />
        <arg value="${build.dir}\XXX.vbs" />
        <arg value="${build.version}" />
    </exec>
    
  4. Lastly, in the case your VB script is failing because of invalid arguments (maybe because of spaces in '${build.version}'), use something like the following to debug the VB script:

    WScript.echo "Argument count", wscript.arguments.count
    
    For i = 0 to wscript.arguments.count - 1
        Wscript.Echo wscript.arguments.item(i)
    Next
    

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文