如何使用 msbuild 获取 exec 任务输出 [英] How get exec task output with msbuild
本文介绍了如何使用 msbuild 获取 exec 任务输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过 msbuild
的 exec 任务获得简单的输出:
I'm trying to get simple output by exec task with msbuild
:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Test">
<Exec Command="echo test output">
<Output TaskParameter="Outputs" ItemName="Test1" />
</Exec>
<Exec Command="echo test output">
<Output TaskParameter="Outputs" PropertyName="Test2" />
</Exec>
<Message Text="----------------------------------------"/>
<Message Text="@(Test1)"/>
<Message Text="----------------------------------------"/>
<Message Text="$(Test2)"/>
<Message Text="----------------------------------------"/>
</Target>
</Project>
但是得到下一个输出:
echo test output
test output
echo test output
test output
----------------------------------------
----------------------------------------
----------------------------------------
如何通过我的脚本获得输出?
How can I get output by my script?
推荐答案
大家好消息!从 .NET 4.5 开始,您现在可以从 <Exec>
捕获输出.
Good news everyone! You can now capture output from <Exec>
as of .NET 4.5.
像这样:
<Exec ... ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
</Exec>
简单地说:
- 将
ConsoleToMsBuild="true"
添加到您的<Exec>
标记 - 使用
<Output>
标签中的ConsoleOutput
参数捕获输出
- Add
ConsoleToMsBuild="true"
to your<Exec>
tag - Capture the output using the
ConsoleOutput
parameter in an<Output>
tag
终于!
这篇关于如何使用 msbuild 获取 exec 任务输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文