NANT 构建错误:Cmd
我正在尝试执行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来“cmd”正在运行,您不需要提供完整路径。错误“外部程序失败:cmd(返回代码为 1)”表示“cmd”已运行,但产生了错误。换句话说,您的 VB 脚本(即“XXX.vbs”)失败了。请尝试以下操作来查找实际错误:
验证“${build.dir}\XXX.vbs”的扩展值是否是有效的文件/位置。如果您使用的是相对路径,请仔细检查您的工作目录。
或
从命令行运行 NAnt 脚本。这将为您提供更好的错误消息,例如来自 Windows Script Host 的弹出错误消息。
避免命令窗口,重定向程序的输出。将“>> exec.log”附加到“exec”任务中的命令行字符串,然后检查输出/日志文件的内容(即“exec.log”)。
或者,使用“exec”任务的更好方法是使用嵌套的“arg”元素。如果你的论点中有空格,这会有所帮助;你的脚本会读起来更清晰:
最后,如果您的 VB 脚本由于无效参数(可能是因为“${build.version}”中的空格)而失败,请使用如下所示的内容来调试 VB 脚本:
:这有帮助。
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:
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.
or
Run your NAnt script from the command line. This will give you a better error message, like a popup error from Windows Script Host.
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').
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:
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:
Hope this helps.