Set verbosity of logging during Tfs 2010 build

To test a little bit how you can log information during a TFS 2010 build you can create a simple activity , this activity simply has a Message property and log three messages, at different BuildMessageImportance level

image

The utility function is the following one

image

Really simple isn’t it? :). Now you need to insert this custom action inside a standard tfs build definition file, to make this happens I need to remind you that you need to include the xaml build definition file in a project included in a solution where your custom action is defined, if not you cannot use the designer and you need to manually edit xaml file.

To easy this process I branched directly the build definition file, with this simple trick, I edit the definition file in my test project, do a check-in and when I want to update the real build definition I do a simple merge. Then I insert my action in the build process. So I created a new build definition from the default template, configure it, then branched into my test project.

image

I highlighted the two important facts: 1) the file is included in the project DotNetMarche.Activities.Workflow.Test, 2) The project with the action is included in the solution, now I can drop the LogSample action into the build definition file using the graphical editor, check-in, merge and launch the build with the new definition (I remember you that you need to deploy also the custom activity as described here), here is the result.

image

As you can verify, only the message with BuildMessageImportance.High is showed, this because the entire build process has an argument that determines the level of log verbosity. Now try to change this value to Detailed. You should click the “Arguments” and locate the Verbosity argument.

image

Now change it to Detailed, check-in, merge ;) and launch the build again to verify the result.

image

Now you can see that in “Detailed” level of verbosity, the workflow logs even the Normal level. The morale is that in your custom activity you should use BuildMessageImportance with great care. Really important messages must be showed with High importance, detailed with Normal, and you should use Low for really verbose messages. But remember, always do a verbose log, because if something gets wrong in the build, you can always change the BuildVerbosity level and verify in detail what is really gone wrong in your custom action.

Alk.

Tags:

Published by

Ricci Gian Maria

.Net programmer, User group and community enthusiast, programmer - aspiring architect - and guitar player :). Visual Studio ALM MVP

5 thoughts on “Set verbosity of logging during Tfs 2010 build”

  1. It looks like the RTM of TFS 2010 changed the BuildMessage to be an internal class, so this sample doesn’t work anymore. Have a look at http://www.ewaldhofman.nl/post/2010/05/28/Customize-Team-Build-2010-e28093-Part-8-Send-information-to-the-build-log.aspx for a more up-to-date means of build logging.

    IIRC there might also be issues with log message buffering, in that you won’t see your messages until the task has finished, so if it’s a long running task, don’t expect instant progress updates.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.