收集来自MSBuild执行任务的输出 [英] Gathering outputs from an MSBuild exec task

查看:57
本文介绍了收集来自MSBuild执行任务的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要从MSBuild项目中调用的批处理脚本,并且文档说我不能在MSBuild项目中使用批处理的输出(控制台/环境变量).

I have a batch script that I want to call from an MSBuild project, and the documentation says I can't use output from the batch (either console / environment variables) in the MSBuild project.

有解决方法吗?

推荐答案

您可以使用> output.txt将命令的输出重定向到文件,并将其读入变量.

You can redirect the output of the command to a file using "> output.txt" and read that into a variable.

<PropertyGroup>
   <OutputFile>$(DropLocation)\$(BuildNumber)\Output.txt</OutputFile>
</PropertyGroup>
<Exec Command="dir > &quot;$(OutputFile)&quot;" />
<ReadLinesFromFile File="$(OutputFile)">
   <Output TaskParameter="Lines" ItemName="OutputLines"/>
</ReadLinesFromFile>
<Message Text="@(OutputLines->'%(Identity)', '%0a%0d')" />

这篇关于收集来自MSBuild执行任务的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆