what happens before msbuild decides to build a target?

there are several elements to processing a target tag:  processing its dependencies, processing the condition, and performing TLDA (top level dependency analysis) or up-to-date checks.  it can be confusing to figure out if a target will execute or not, so we on the msbuild team toss around a nifty mnemonic to help us remember (originally pointed out by rajeev, as far as i can remember).  this is the order in which msbuild processes the attributes of a target element:

  • Condition
  • DependsOnTargets
  • Inputs
  • Outputs

notice they're in alphabetical order.  first, msbuild will evaluate the Condition.  if the Condition is false, msbuild skips the target (and never even bothers looking at the DependsOnTargets attribute).  if the Condition is true, msbuild will then execute each of the targets listed in DependsOnTargets.  once the dependencies have been built, it will then examine the Inputs and Outputs to determine if the target even needs to be built, or if it can be partially built (do you know what this means?).  then msbuild can actually begin running your tasks....

[ Author: Jeffery Callahan ]

Comments (0)

Skip to main content