Echo linebreak to file using Phing on Windows

拟墨画扇 提交于 2019-12-10 02:11:40

问题


In my build script I'm trying to output the date and SVN revision number to a file in the build directory. I would like the date and revision number on separate line, but can't get a linebreak to output to the file. I've tried all sorts of methods:

    <echo file="${build.dir}\build.txt">DATE = ${DATE} \r\n \\\r\\\n PHP_EOL</echo>
    <echo msg="DATE: ${DATE} \r\n \\\r\\\n PHP_EOL 0x0D0A SVN revision: ${svn.lastrevision} . PHP_EOL" file="${build.dir}\build.txt" append="true" />

Has anyone else managed to get a linebreak through to file with Phing? I've looked at the code in phing, and it uses fwrite. I can only guess the strings in my build.xml are getting escaped in some way before being handled by fwrite?

I guess I may have to resort to using ExecTask?


回答1:


You can make use of ${line.separator}, see Built-In PropertiesDocs.

<echo msg="DATE: ${DATE}${line.separator}SVN revision: ${svn.lastrevision}${line.separator}" file="${build.dir}\build.txt" append="true" />


来源:https://stackoverflow.com/questions/6995019/echo-linebreak-to-file-using-phing-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!