开发者

Gathering outputs from an MSBuild exec task

开发者 https://www.devze.com 2022-12-08 05:35 出处:网络
I have a batch script that I want to call from an MSBuild project, and the documentation s开发者_如何学JAVAays I can\'t use output from the batch (either console / environment variables) in the MSBuil

I have a batch script that I want to call from an MSBuild project, and the documentation s开发者_如何学JAVAays I can't use output from the batch (either console / environment variables) in the MSBuild project.

Is there a workaround?


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

精彩评论

暂无评论...
验证码 换一张
取 消