What is Microsoft.TeamFoundation.Build.targets?
Targets file is any valid MSBuild script that contains the definitions of targets, tasks, properties, items, etc. The file should end with the extension of .targets. MSBuild ships with several standard .targets files. You can refer this link for more details.
Microsoft.TeamFoundation.Build.targets file is standard file that we ship with Visual Studio Team System. It defines the entire build process. Srivatsn already has a blog about it but I will be giving some more details.
Guidelines about targets file
- We strongly discourage you to modify the targets file. If you want to add additional properties or items or want to introduce custom targets and tasks, please use the corresponding proj file. The targets file defines the generic build process. If you make any change in the targets file, then all the subsequent builds will be affected.
- Targets file is not localized in present release. We will try to fix this in future release.
- If you redefine any property/task/target in proj files, it will override the standard definition mentioned in targets file.
- There are skip flags/properties defined in the targets file. You can redefine them in the proj file to skip specific build steps. The details on how to introduce new targets/tasks or customize the build process can be found here.
Details about the file content
- CheckSettingsForEndToEndIteration target (specified by InitialTargets tag) is the constructor and does the basic validation for required environment variables and properties. Please note that this target will not be executed for the desktop build.
- DesktopBuild target launches the desktop build. It will internally invoke desktop clean and compile targets.
- EndToEndIteration target is the entry point for Team Build build process. This target is invoked by the build agent on the build machine. It defines the entire build process that consists of initialization phase (which includes clean the old redundant files, creating enlistment from source control, syncing files), build phase, running and publishing tests phase, generating build metrics phase and final phase (consisting of copying the binaries to drop location or creating bugs on build break).
- CoreCompile target is responsible for building the sources. It internally uses Microsoft.Common.targets file to invoke the project specific compiler with proper parameters.
- Similarly CoreTest target is responsible for invoking and publishing the tests. Please note that we are spanning a separate MSBuild process for running tests for different platform/configuration. This is because we want to do target batching on two different types of itemgroups (ConfigurationToBuild and MetaDataFile). MSBuild currently support target batching on only one itemgroup type. It has performance implications but currently this is the best way to achieve the desired result. We are communicating with MSBuild team and will try to find a better way.
Please let me know if you want specific detail about anything in this file. Hope it helps !!!