msbuild - How to clear (and possibly include other) items from an ItemGroup? -
in build process, i'm using pattern, whereby somes tasks designed compute list of items in item group, , other tasks create physical corresponding items.
this allows me minimize build times performing incremental build.
in 1 of our project, need manipulate items in itemgroup
. first attempt, first, clear contents of itemgroup
, then, include ones i'm interested itemgroup
.
however, stumbled upon behavior of msbuild not make sense me. issue, trying clear items from itemgroup
when particular target
executes. is, if, after analysing inputs
, outputs
attributes, msbuild determines target
must executed.
here minimal code snippet reproduce problem:
<target name="computecustomitemgroup"> <createitem include="c:\temp\fichier1.ext;c:\temp\fichier2.ext;"> <output taskparameter="include" itemname="customitemgroup" /> </createitem> </target> <target name="createcustomitemgroup" dependsontargets="computecustomitemgroup" inputs="c:\temp\input" outputs="c:\temp\output"> <message text="creating custom item group..." /> <!-- ability clear item group *only* when target executed --> <!-- clears item group every time appears in dependency chain of executing target ! --> <itemgroup> <customitemgroup remove="@(customitemgroup)" /> </itemgroup> </target> <target name="customtarget" dependsontargets="createcustomitemgroup"> <message text="executing custom target..." /> <!-- here, @(customitemgroup) empty... --> <message text="customitemgroup: @(customitemgroup)" /> </target> <target name="build" dependsontargets="customtarget" /> </project>
in code sample above, @(customitemgroup)
set collection containing couple of file paths. that's fine.
now, if create 2 files, @ following locations c:\temp\input , c:\temp\output (one after other, obviously), result of sample code above @(customitemgroup)
comes empty, though target name="createcustomitemgroup"
not executed.
i've tried using legacy createitem
way manipulate itemgroup
s not find safisfying answer.
can suggest workaround?
you facing "output inference" described here http://msdn.microsoft.com/en-us/library/vstudio/ee264087%28v=vs.100%29.aspx
the target has no out-of-date outputs , skipped. msbuild evaluates target , makes changes items , properties if target had been run.
consider re-designing logic use condition statements assignments.
Comments
Post a Comment