Jaa


TFS 2010 – Making Your Build Log Less Noisy

So, I have been asked this question a couple of times now and so I decided to put it out there for everyone. If you are creating custom build templates that do a lot of looping or other work that seems to make the build log way too noisy, you may want to hide some of that. Well, we had the same problem when creating the default template. It does a lot of work that no one really cares about most of the time. And sometimes we had to include a Sequence to hold our activities that was not really useful to log in the activity log.

So, what logs this stuff anyway? Well, Windows Workflow allows the host process to attach a custom Tracking Participant. This allows the host process to listen to all the work that the Workflow is doing. It also allows our custom activities to send messages to the host process. For the purposes of this post, I just want to talk about one aspect of this listener – the importance of tracking individual activities.

We added an Attached Property that can be added to all activities so that the build process template can specify how an activity should be tracked in the log. That attached property looks like this in the XAML file:

mtbwt:BuildTrackingParticipant.Importance="None"

There are four values that we recognize:

None – don’t log this activity at all

Low – only log this activity if the build verbosity is set to Diagnostic or Detailed

Normal – only log this activity if the build verbosity is set to Normal, Detailed, or Diagnostic.

High – always track this activity

Normal as you might have guessed is the default value if you don’t set one. And since the verbosity also defaults to normal, any activities that you add that don’t specify this attribute will automatically be logged.

Now, here is the real kicker. The Windows Workflow designer inside Visual Studio does not show you attached properties. So, to set and maintain these values, you must open the workflow in the XML editor (use the Open With option on the File Open dialog in VS). For this reason, we use these attributes sparingly, but you will see it on the first activity in the default template – a Sequence that doesn’t need to be logged.

Personally, I don’t think there is a great reason to ever use the “None” value. If you have a loop or other activities that are adding a lot of noise to the log, I recommend that you use the value “Low”. Then if something is going wrong, you can turn on Diagnostic output and see everything that’s happening in the log.

Happy Building!

Comments

  • Anonymous
    September 05, 2011
    Using the standard activity ConvertWorkspaceItems, it creates a lot of noise: Sequence    Assign<IList<String>>        ForEach<String>            If                AddToCollection<String>                    ConvertWorkspaceItem The last three repeated the number items to convert. And this is even though I added mtbwt:BuildTrackingParticipant.Importance="Low" to the activity. Any ideas how to avoid this?

  • Anonymous
    February 01, 2012
    Thanks for your valuable post. But I'm getting VisualBasicValue<Boolean> as a return of <While.Condition>. Could you please help me out how to rectify the return type? Thanks in advance Regards Murugesan kumarasamy

  • Anonymous
    October 08, 2014
    Very good explanation ! Saved lot of my time.