msbuild - Processing batch items in parallel -


i have itemgroup, , want process items in parallel (using custom task or .exe).

  • i write task/exe accept entire itemgroup , process items in parallel internally. however, want parallelism work in conjunction msbuild's /maxcpucount param, since otherwise might end over-parallelizing.
  • this thread says there's no way.
  • my testing shows msbuild's /maxcpucount works building different projects, not items (see code below)

how can process items itemgroup in parallel?
there way author custom task work in parallel in conjunction msbuild's parallel support?

<project toolsversion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">   <target name="build" >     <!-- runs once - guess msbuild detects it's same project -->     <!--<msbuild projects="$(msbuildprojectfullpath);$(msbuildprojectfullpath)" targets="wait3000" buildinparallel="true" />-->      <!-- runs in parallel!. note b.targets copy of original a.targets -->     <msbuild projects="$(msbuildprojectfullpath);b.targets" targets="wait3000" buildinparallel="true" />      <!-- runs sequentially -->     <itemgroup>       <waits include="3000;2000"/>     </itemgroup>     <wait durationms="%(waits.identity)" />   </target>    <target name="wait3000">     <wait durationms="3000" />   </target>    <usingtask taskname="wait" taskfactory="codetaskfactory" assemblyfile="$(msbuildtoolspath)\microsoft.build.tasks.v4.0.dll" >     <parametergroup>       <durationms parametertype="system.int32" required="true" />     </parametergroup>     <task>       <code type="fragment" language="cs">         log.logmessage(string.format("{0:hh\\:mm\\:ss\\:fff}  start  durationms={1}", datetime.now, durationms), messageimportance.high);         system.threading.thread.sleep(durationms);         log.logmessage(string.format("{0:hh\\:mm\\:ss\\:fff}  end    durationms={1}", datetime.now, durationms), messageimportance.high);       </code>     </task>   </usingtask> </project>    

i know old, if few minutes, revisit attempt use msbuild task. using properties and/or additionalproperties reserved item metadata elements* resolve issue described in code sample ("runs once - guess msbuild detects it's same project").

the msbuild file below processes items itemgroup in parallel via msbuild's parallel support (including /maxcpucount). not use buildtargetsinparallel msbuild extension pack, nor other custom or inline task.

<project toolsversion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">    <target name="build" >     <itemgroup>       <waits include="3000;2000"/>     </itemgroup>      <itemgroup>       <projectitems include="$(msbuildprojectfullpath)">         <properties>           waitms=%(waits.identity)         </properties>       </projectitems>     </itemgroup>     <msbuild projects="@(projectitems)" targets="waitspecifiedms" buildinparallel="true" />   </target>    <target name="waitspecifiedms">     <wait durationms="$(waitms)" />   </target>  </project> 

* well-hidden under "properties metadata" on msbuild task reference page.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -