我试图通过 exec 任务获得简单的输出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
----------------------------------------
----------------------------------------
----------------------------------------
我怎样才能通过我的脚本获得输出?
大家好消息!您现在可以捕获输出<Exec>
从 .NET 4.5 开始。
像这样:
<Exec ... ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
</Exec>
Simply:
- Add
ConsoleToMsBuild="true"
给你的<Exec>
tag
- 使用捕获输出
ConsoleOutput
中的参数<Output>
tag
Finally!
文档在这里 https://learn.microsoft.com/dotnet/api/microsoft.build.tasks.exec
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)