Customize Team Build 2010 – Part 8: Send information to the build log?

by Ewald Hofman 27. May 2010 21:45

In the series the following parts have been published

  1. Part 1: Introduction
  2. Part 2: Add arguments and variables
  3. Part 3: Use more complex arguments
  4. Part 4: Create your own activity
  5. Part 5: Increase AssemblyVersion
  6. Part 6: Use custom type for an argument
  7. Part 7: How is the custom assembly found
  8. Part 8: Send information to the build log
  9. Part 9: Impersonate activities (run under other credentials)
  10. Part 10: Include Version Number in the Build Number
  11. Part 11: Speed up opening my build process template
  12. Part 12: How to debug my custom activities
  13. Part 13: Get control over the Build Output
  14. Part 14: Execute a PowerShell script
  15. Part 15: Fail a build based on the exit code of a console application
  16. Part 16: Specify the relative reference path

In the build you can set the verbosity to different levels to get diagnostic information from the activities that are executed. The information from the activities that come out of the box are great, but if you could add your own diagnostic information would be wonderful.

 

To add this information is pretty simple.

  1. Add a reference to the Microsoft.TeamFoundation.Build.Workflow assembly. You can find it in the folder C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies
  2. Then add a using statement to the namespace Microsoft.TeamFoundation.Build.Workflow.Activities
  3. You can now add the line context.TrackMessage(“My diagnostic information”); to show the information in the build log. You can also specify the importance of the message to indicate in which Verbosity it will be shown. The following table shows when the message will be shown.

    Verbosity Importance
    Minimal -
    Normal High
    Detailed Normal
    Diagnostic Low

I created an activity with an argument that reports that argument back to the build log, also with the different possibilities of presenting the information.

using System.Activities;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Build.Workflow.Activities;

namespace BuildTasks.Activities
{

    [BuildActivity(HostEnvironmentOption.All)]
    public sealed class DiagnosticInformation : CodeActivity
    {
        public InArgument<string> TextIn { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            string textIn = context.GetValue(this.TextIn);

            context.TrackBuildMessage("Message: " + textIn);
            context.TrackBuildMessage("Message (High importance): " + textIn, BuildMessageImportance.High);
            context.TrackBuildMessage("Message (Normal importance): " + textIn, BuildMessageImportance.Normal);
            context.TrackBuildMessage("Message (Low importance): " + textIn, BuildMessageImportance.Low);
            context.TrackBuildError(textIn);
            context.TrackBuildWarning(textIn);
        }
    }
}

When you run add the activity to your Build Process Template and run the build, you will see the following result for the different verbosities.

Verbosity Result
Diagnostic image
Detailed image
Normal image
Minimal image

 

You can download the full solution at BuildProcess.zip. It will include the sources of every part and will continue to evolve.

Tags:

Team Build | VSTS 2010

Comments

11/9/2010 5:32:34 AM #

trackback

Part 14: Execute a PowerShell script

Part 14: Execute a PowerShell script

Ewald Hofman |

11/10/2010 9:14:27 AM #

pingback

Pingback from blogs.like10.com

TechDays 2010 Presentations « Microsoft Team Foundation Server, SharePoint Server, .NET, and SQL Server

blogs.like10.com |

5/31/2011 8:22:10 AM #

trackback

Ewald’s posts on TFS Build 2010

Ewald Hofman , an ALM MVP, has written a great series of blog posts on Team Build in Team Foundation Server 2010.  The 2010 release introduces Windows Workflow as the overall orchestrator of the build process.  Ewald walks you through quite a few topics related to this and the other new features.  Check it out! Part 1: Introduction Part 2: Add arguments and variables Part 3: Use more complex arguments Part 4: Create your own activity Part 5: Increase AssemblyVersion Part 6: Use custom type for an argument Part 7: How is the custom assembly found Part 8: Send information to the build log Part 9: Impersonate activities (run under other credentials) Part 10: Include Version Number in the Build Number Part 11: Speed up opening my build process template Part 12: How to debug my custom activities Part 13: Get control over the Build Output Part 14: Execute a PowerShell script Part 15: Fail a build based on the exit code of a console application Part 16: Specify the relative reference path Technorati Tags: tfs 2010 , team build , windows workflow

Buck Hodges |

5/31/2012 4:53:17 AM #

pingback

Pingback from dkphp.com

TFS 2010 Show Output In Log Window | PHP Developer Resource

dkphp.com |

Comments are closed

Powered by BlogEngine.NET 1.6.1.0
Theme by Mads Kristensen


ClusterMap

Statistics

Statistics created at 09 Sep 2009

121 posts
487 comments
316 raters
1758914 visit (1044 per day)
17 users online

Recent comments

Comment RSS