Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gathering outputs from an MSBuild exec task

Tags:

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.

Is there a workaround?

like image 501
ripper234 Avatar asked Oct 05 '09 10:10

ripper234


1 Answers

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')" />
like image 81
Dave Avatar answered Sep 21 '22 07:09

Dave