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
The utility function is the following one
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.
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.
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.
Now change it to Detailed, check-in, merge ;) and launch the build again to verify the result.
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.