Amongst the new activities shipped with Team Foundation Server 2012, I have found the WriteCustomSummaryInformation activity to be very useful. It is a very simple activity with only four properties and can be dragged and dropped anywhere into your build process template to create a custom summary section or write to an existing summary section. There is a good post about using this activity on MSDN.
However, if you are writing your own activity and need to write to the build’s summary, the activity is not really useful. In this blog post, I will demonstrate how to write to the build summary from within custom activity activity. The class that enables you to write to the build summary area is “CustomSummaryInformation” and it is present in the Microsoft.TeamFoundation.Build.Workflow.dll assembly. In order to inform the team build to register the custom summery information, you would need to call the Track method of the CodeActivityContext class as demonstrated below
1: private void WriteSummaryInformation(string key, int priority, string heading, string message)
3: this.ActivityContext.Track(new CustomSummaryInformation()
5: SectionPriority = priority,
6: Message = message,
7: SectionHeader = heading,
8: SectionName = key
As, you can see, writing to the build summary is as simple as creating a new CustomSummaryInformation and tracking it with the activity context. TFS Build has a custom tracking participant with functionality to track objects of types such as BuildError, BuildInformationRecord, BuildMessage, etc. In fact, there are extension methods present to track types BuildError, BuildMessage and BuildWarning. There are not such extension methods available yet for CustomSummaryInformation.