msbuild - Can you do parallel incremental building on a list of projects? -


is possible take list of projects , parallel build them if aren't date?

<target name="dependencieslevel7" dependsontargets="dependencieslevel6"> <message text="5 items build" /> <msbuild projects="c:\projects\applicationmanager.csproj;c:\projects\metrics.csproj" properties="$(customallproperties)" buildinparallel="true">   <output taskparameter="targetoutputs" itemname="built_dependencieslevel7" /> </msbuild> 

this example of format i'm building in, hoping able parallel build items aren't date here? perhaps internal msbuild task calls automatically parallel? if how set it's incremental based on previous build task? (target dependencieslevel6) believed incremental building have use inputs/outputs in target.

question summary:

  • is list of projects passed msbuild task automatically incremental (building skipped if build date)?
    • if not, possible incremental on list of projects while parallelizing?
  • can between target incremental each target parallel build?

what describing "parallel incremental building" built in (kind of) need parallel partially building.

let me first explain concepts , i'll circle how works in scenario specifically. there 2 things need know about; incremental building , partial building. wrote blog post discussing @ http://sedodream.com/2010/09/23/msbuildyouveheardofincrementalbuildingbuthaveyouheardofpartialbuilding.aspx i'll paste relevant parts here.

incremental building concept should build out of date. support msbuild has attributes, inputs , outputs on target element. these attributes can specify files go target (via inputs attribute), , files expecting come out of target (via outputs attribute). once msbuild compare timestamp of inputs outputs , if outputs up-to-date (i.e. inputs older) target skipped. take @ simple project file below.

<project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">    <itemgroup>     <files include="src\01.txt;src\02.txt;src\03.txt;src\04.txt;src\05.txt;"/>   </itemgroup>    <propertygroup>     <dest>dest\</dest>   </propertygroup>    <target name="copyfiles"            inputs="@(files)"            outputs="@(files->'$(dest)%(filename)%(extension)')">      <message text="copyfiles" />     <copy sourcefiles="@(files)"           destinationfiles="@(files->'$(dest)%(filename)%(extension)')"/>   </target>    <target name="deletetwofiles">     <message text="deletetwofiles" />     <delete files="$(dest)01.txt;$(dest)02.txt"/>   </target> </project> 

in project file have 2 targets; copyfiles , deletetwofiles. ignore deletetwofiles now. take note directory i’m executing build has folder, src, files listed in files item. on copyfiles target have specified inputs , outputs. inputs @(files), files target acting upon. outputs contains expression @(files->'$(dest)%(filename)%(extension)'). same expression copy statement. if dest folder empty , execute copyfiles target result shown below.

alt text

so expected files copied over, good. happens if execute again? output shown below

alt text

so can see target skipped, message statement “copyfiles” not executed nor copy result. this, in nutshell, incremental building. now, dest folder containing files, think happen execute command msbuild.exe partialbuilding01.proj /t:deletetwofiles;copyfiles? command first delete 2 files output directory , call copyfiles target again. let’s see result below.

alt text

when copyfiles target executed see statement “building target ‘copyfiles’ partially, …”. when time came execute target msbuild examined inputs , outputs, determined files 01.txt & 02.txt out of date (because didn’t exist in target) 03.txt, 04.txt , 05.txt date. msbuild feed copyfiles target value files item contained 01.txt , 02.txt , let thing.

now relates problem in many ways not direct might hope. firstly msbuild incrementally build project, if project date not built again. thing though in order msbuild determine project date has load project run default target (usually build) , targets figure out there no work do. stuff takes time. if have huge number of projects, or huge number of files inside of project can take matters own hands. need way determine if projects date or not , correctly express inside of inputs , outputs attributes. once should able skip building projects date.

the core of problem how craft inputs/outputs correct. if can think of way want. how craft depend on scenario see this:

  1. after each project build drop file known location specific project
  2. before build project scan directory, find newest file , update timestamp of project file value
  3. then can place project files inputs values , marker files outputs
  4. then call target

in case assume dependencies contained in files under directory of project (which may not true). i'm not saying ideal solution, solution.

==============================================

edit: update based on questoins below.

you want put projects item (though not required) projectfiles , use @(projectfiles) inputs. outputs saying hard part. have figure out way know (or indicate via own process) projects date. there nothing built in this. concern fo incremental build vs. clean build. in perfect world incremental & clean builds same. not case. many projects is. if start adding bunch of targets build process , set them incremental build, not implement may msbuild may skip targets when indeed out of date. example of when create target inputs set list of files , outputs set list of created files. if not extend clean process delete created files, next time rebuild (assuming didn't change files) target skipped when should have been cleaned on previous rebuild.


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -