By design, targets in a MSBuild process are only called once. This is an important concept to understand, as it is unusual for the typical developer.
I had a situation where I wanted to call the same target from a few places in my MSBuild project - but I wanted to pass in different property values. I didn’t want to repeat myself (DRY principle).
<CallTarget ...> is used then the target is only called once within that process.
I found a sneaky way to work around this by examining the file
Instead of using
<CallTarget ...>, use
<MSBuild ...> which spawns off a new MSBuild process, thus allowing the target to be called each time.
1<MSBuild Projects="$(MSBuildProjectFile)" Targets="MyTarget" Properties="MyProperty1=blah;MyProperty2=$(MyVariable)\blah2" />