views:

714

answers:

3

Unless I've grossly misunderstood MSBuild, tasks are executed in the document order in which they appear within a 'Target' node.

I'd like to be able to specify that two tasks (such as xcopy tasks) could run in parallel. I was expecting there to be a 'Parallel' task or something...?

+1  A: 

I don't think there is a way to do this other than using some external tool. I suspect this is because this introduces potential dependency problems that MS chooses to ignore for the time being, allowing external tool vendors to tackle the problem (and charge quite a bit of money for it).

McWafflestix
A: 

MSBuild has a /m command line switch to tell it the maximum number of concurrent processes to build with. The default value is 1. /m:x will use x processes. /m will use up to the number of processors on computer.

I've used this as part of a shortcut in Visual Studio to run builds quicker by compiling projects in parallel. Scott Hanselman has a few posts about it here and here.

adrianbanks
Thanks, but I'm interested in introducing explicit parallelism at the Task level; this works only for non-dependent MSBuild projects as far as I can see. I'll perhaps see if I can transform the tasks into separate projects.
Pete Montgomery
+4  A: 

Hi, As was stated, you cannot parallelise at the task level or even at the target level. MSBuild only will build projects (i.e. MSBuild project files) in parallel. So you have to use the MSBuild task with multiple projects specified and the BuildInParallel attribute should be set to true. Also make sure that when the build is invoked on the command line that the /m switch is sent it.

Sayed Ibrahim Hashimi