NAnt exec不能与stdin重定向一起使用?

时间:2021-09-01 00:05:51

I'm trying to use jsmin with nant - and it just uses stdin and stdout for input and output. The nant 'exec' task allows you to redirect the output to a file, but not get the input from a file.

我正在尝试将jsmin与nant一起使用 - 它只使用stdin和stdout进行输入和输出。 nant'exec'任务允许您将输出重定向到文件,但不能从文件中获取输入。

I have tried with a 'commandline' using '>' and '<' to direct the input and output, but nant just goes away and doesn't come back :(

我尝试使用'''和'<'来指导输入和输出的'命令行',但是nant只是消失而且不会回来:(

I can't believe no-one's tried to do this before. Please help! :)

我不敢相信没有人试图这样做过。请帮忙! :)

3 个解决方案

#1


From http://www.mail-archive.com/nant-developers@lists.sourceforge.net/msg04575.html. You should be able to do something similar to:

来自http://www.mail-archive.com/nant-developers@lists.sourceforge.net/msg04575.html。你应该可以做类似的事情:

        <exec program="cmd.exe" workingdir=".">
                <arg value="/c cacls" />
                <arg value="${mdb.file}" />
                <arg value="/E" />
                <arg value="/G testpc\aspnet:F" />
                <arg value="&lt; y.txt" />
        </exec>

#2


I believe NAnt does support input from a file. Since the build file is XML you must use the xml encoded "<".

我相信NAnt确实支持来自文件的输入。由于构建文件是XML,因此必须使用xml编码的“<”。

<exec program="somefile.exe" workingdir=".">
  <arg value="&lt; input.txt" />
</exec>

#3


The redirect and pipe operators are an feature of the shell, C and C# support redirection by other means (file handles). Somewhere I read that because the C# Process class did not support input redirection, nant provides only output redirection for <exec>.

重定向和管道运算符是shell的一个特性,C和C#通过其他方式支持重定向(文件句柄)。在某处我读到,因为C#Process类不支持输入重定向,nant只为 提供输出重定向。

To redirect command input we can resort to the shell:

要重定向命令输入,我们可以求助于shell:

A) Invoking cmd.exe with /c as shown in the example of acloutier above. Care must be taken with whitespaces! Actually the example fails due to the space between < and y.txt, remove it to make the example work. You can can also convert the value attribute in a line attribute but then you have to be careful with quoting.

A)使用/ c调用cmd.exe,如上面的acloutier示例所示。必须注意空白!实际上,由于 <和y.txt之间的空格,示例失败,删除它以使示例工作。您也可以在行属性中转换value属性,但是您必须小心引用。< p>

B) Since I could not get pipes to work using the exec-cmd approach, instead I am generating a batch-file on the fly using <echo>:

B)由于我无法使用exec-cmd方法使管道工作,而是使用 动态生成批处理文件:

<echo file="${WD}/login.bat">"${P4}" diff -sd | "${P4}" -x- sync -f using</echo>        
<exec program="login.bat" basedir="${WD}" workingdir="${P4.WorkspaceRoot}" />

#1


From http://www.mail-archive.com/nant-developers@lists.sourceforge.net/msg04575.html. You should be able to do something similar to:

来自http://www.mail-archive.com/nant-developers@lists.sourceforge.net/msg04575.html。你应该可以做类似的事情:

        <exec program="cmd.exe" workingdir=".">
                <arg value="/c cacls" />
                <arg value="${mdb.file}" />
                <arg value="/E" />
                <arg value="/G testpc\aspnet:F" />
                <arg value="&lt; y.txt" />
        </exec>

#2


I believe NAnt does support input from a file. Since the build file is XML you must use the xml encoded "<".

我相信NAnt确实支持来自文件的输入。由于构建文件是XML,因此必须使用xml编码的“<”。

<exec program="somefile.exe" workingdir=".">
  <arg value="&lt; input.txt" />
</exec>

#3


The redirect and pipe operators are an feature of the shell, C and C# support redirection by other means (file handles). Somewhere I read that because the C# Process class did not support input redirection, nant provides only output redirection for <exec>.

重定向和管道运算符是shell的一个特性,C和C#通过其他方式支持重定向(文件句柄)。在某处我读到,因为C#Process类不支持输入重定向,nant只为 提供输出重定向。

To redirect command input we can resort to the shell:

要重定向命令输入,我们可以求助于shell:

A) Invoking cmd.exe with /c as shown in the example of acloutier above. Care must be taken with whitespaces! Actually the example fails due to the space between < and y.txt, remove it to make the example work. You can can also convert the value attribute in a line attribute but then you have to be careful with quoting.

A)使用/ c调用cmd.exe,如上面的acloutier示例所示。必须注意空白!实际上,由于 <和y.txt之间的空格,示例失败,删除它以使示例工作。您也可以在行属性中转换value属性,但是您必须小心引用。< p>

B) Since I could not get pipes to work using the exec-cmd approach, instead I am generating a batch-file on the fly using <echo>:

B)由于我无法使用exec-cmd方法使管道工作,而是使用 动态生成批处理文件:

<echo file="${WD}/login.bat">"${P4}" diff -sd | "${P4}" -x- sync -f using</echo>        
<exec program="login.bat" basedir="${WD}" workingdir="${P4.WorkspaceRoot}" />