I have an msbuild script that performs some copy operations. It actually does a whole boat load of copies and other things, including messages, deletes, removedir, its own ItemGroup sections, etc.
I need to duplicate this target but only 1%-ish of its XML is different. At the moment, it's just adding 1 additional task. I don't want to copy & paste the whole target, I'd rather set up a common target to execute the tasks common to both, and put the specialized additions in a separate target. More or less I just want msbuild to copy/paste the contents of the XML into each section for me, behaviorally.
Here is an example:
<Target Name="Copy Stuff">
<Copy SourceFiles="@(FILES_STUFF1)" DestinationFolder="$(BASE_DIR)\stuff1"/>
<Copy SourceFiles="@(FILES_STUFF2)" DestinationFolder="$(BASE_DIR)\stuff2"/>
<Copy SourceFiles="@(FILES_STUFF3)" DestinationFolder="$(BASE_DIR)\stuff3"/>
</Target>
I then need to create a 2nd target that only adds 1 extra Copy
:
<Target Name="Copy Stuff More">
<Copy SourceFiles="@(FILES_STUFF1)" DestinationFolder="$(BASE_DIR)\stuff1"/>
<Copy SourceFiles="@(FILES_STUFF2)" DestinationFolder="$(BASE_DIR)\stuff2"/>
<Copy SourceFiles="@(FILES_STUFF3)" DestinationFolder="$(BASE_DIR)\stuff3"/>
<Copy SourceFiles="@(FILES_STUFF4)" DestinationFolder="$(BASE_DIR)\stuff4"/>
</Target>
How can I centralize the duplicated XML pieces? I read a little about msbuild batching but it makes absolutely zero sense to me. I am not confident it will solve my problem. All of the examples of it I've seen have been for Message logs, but I'm doing far more than that.