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

查看:25
本文介绍了从 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天全站免登陆