Reputation: 40002
I am batching multiple exec
tasks in the build process. 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:
<Target Name="CreatePackages" DependsOnTargets="Build" AfterTargets="Build">
<Exec Command="SomeExecutable.exe %(SomeGroup.Location) </Exec>
</Target>
The ItemGroup
definition:
<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?
Upvotes: 2
Views: 2519
Reputation: 10432
MSBuild doesn't parallelize on task or target level, but on project level only. 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).
Upvotes: 1