[英]Running multiple exec tasks in parallel
I am batching multiple exec
tasks in the build process. 我正在构建过程中批处理多个
exec
任务。 Each execution takes around one minute to complete, so I would like to run them in parallel to improve overall build performance. 每次执行大约需要一分钟才能完成,因此我想并行运行它们以提高整体构建性能。
The target that run multiple exec
tasks: 运行多个
exec
任务的目标:
<Target Name="CreatePackages" DependsOnTargets="Build" AfterTargets="Build">
<Exec Command="SomeExecutable.exe %(SomeGroup.Location) </Exec>
</Target>
The ItemGroup
definition: ItemGroup
定义:
<ItemGroup>
<SomeGroup Include="Production">
<Location>SomePath/Production</Location>
</SomeGroup>
<SomeGroup Include="Test">
<Location>SomePath/Test</Location>
</SomeGroup>
<SomeGroup Include="Development">
<Location>SomePath/Development</Location>
</SomeGroup>
</ItemGroup>
How do I run these exec
tasks in parallel? 如何并行运行这些
exec
任务?
MSBuild doesn't parallelize on task or target level, but on project level only. MSBuild不在任务或目标级别并行化,而仅在项目级别并行化。 You choices are to wrap each individual location in a target and call project itself in parallel (messy), or to write a custom task with TPL (
System.Threading.Tasks.Parallel
) and Microsoft.Build.Tasks.Exec
or System.Diagnostics.Process
(easy), or try YieldDuringToolExecution (technically not parallelization, but other tasks would wait less). 您的选择是将每个单独的位置包装在目标中,并并行(混乱)调用项目本身,或者使用TPL(
System.Threading.Tasks.Parallel
)和Microsoft.Build.Tasks.Exec
或System.Diagnostics.Process
编写自定义任务System.Diagnostics.Process
(简单),或尝试使用YieldDuringToolExecution (从技术上讲不是并行化,但是其他任务等待的时间会更少)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.