Gathering outputs from an MSBuild exec task

后端 未结 1 401
难免孤独
难免孤独 2021-01-03 23:47

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

相关标签:
1条回答
  • 2021-01-04 00:08

    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 讨论(0)
提交回复
热议问题