tbi*_*icr 76 msbuild exec msbuild-task
我试图通过exec任务得到简单的输出msbuild:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Test">
<Exec Command="echo test output">
<Output TaskParameter="Outputs" ItemName="Test1" />
</Exec>
<Exec Command="echo test output">
<Output TaskParameter="Outputs" PropertyName="Test2" />
</Exec>
<Message Text="----------------------------------------"/>
<Message Text="@(Test1)"/>
<Message Text="----------------------------------------"/>
<Message Text="$(Test2)"/>
<Message Text="----------------------------------------"/>
</Target>
</Project>
Run Code Online (Sandbox Code Playgroud)
但得到下一个输出:
echo test output
test output
echo test output
test output
----------------------------------------
----------------------------------------
----------------------------------------
Run Code Online (Sandbox Code Playgroud)
如何通过我的脚本输出?
Avi*_*rry 133
大家好消息!您现在可以捕获<Exec>.NET 4.5中的输出.
像这样:
<Exec ... ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
</Exec>
Run Code Online (Sandbox Code Playgroud)
只是:
ConsoleToMsBuild="true"到您的<Exec>标记ConsoleOutput参数捕获输出<Output>最后!
我已经到了这样的地步,我对MSBuild的局限性感到非常沮丧,以及那些应该工作但却没有(至少不是在每个环境中)的东西,几乎任何时候我都需要对MSBuild做任何事情,我在C#中创建自定义构建任务.
如果其他建议都没有起作用,那么你当然可以这样做.
小智 6
如果要将输出捕获到类似数组的结构而不是输出行由分号分隔的纯字符串,请使用ItemName而不是PropertyName:
<Exec ... ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" ItemName="OutputOfExec" />
</Exec>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
30567 次 |
| 最近记录: |