Gathering outputs from an MSBuild exec task

☆樱花仙子☆ 提交于 2019-12-18 18:58:21

问题


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.

Is there a workaround?


回答1:


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')" />


来源:https://stackoverflow.com/questions/1519177/gathering-outputs-from-an-msbuild-exec-task

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!