Question on "CoreCompile" target in file Microsoft.TeamFoundation.Build.targets?

Why invoke targets through call to “MSBuild” instead of using DependsOnTargets and dividing up the targets accordingly?

MSBuild task is a standard task shipped with .NET Framework (refer It is used to build both solutions (sln) and projects (.xxproj) files. In Team Build we are using MSBuild tasks to call build and publish targets on the sln files that user has asked us to build. The build and publish are standard MSBuild targets for solutions (refer Microsoft.Common.Targets). Please note that sln file is not MSBuild formatted file and MSBuild does some special processing to convert it into MS Build formatted in-memory representation. The build or publish targets are invoked on this in-memory representation.

Why are we not using "DependsOnTargets"?

Consider a scenario where you are building 2 solutions Sln1.sln (consoleApp1.csproj) and Sln2.sln (consoleApp2.csproj). If you use the DependsOnTargets, you have to run “for” loop for each sln file and call the corresponding compile target. In our case, MSBuild task internally does all the processing. This results in a much better and more readable target file.