O'Reilly logo

Inside the Microsoft® Build Engine: Using MSBuild and Team Foundation Build by William Bartholomew, Sayed Ibrahim Hashimi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Your First Task

As many other texts do, we will create a Hello World example. This simple example, which follows, was taken from the HelloWorld.cs file.

public class HelloWorld : ITask
{
    public IBuildEngine BuildEngine
    { get; set; }
    public ITaskHost HostObject
    { get; set; }

    public bool Execute()
    {
        // set up support for logging
        TaskLoggingHelper loggingHelper = new TaskLoggingHelper(this);
        loggingHelper.LogMessageFromText(
           "Hello MSBuild", MessageImportance.High);

        return true;
     }
}

In this first example, we have created a HelloWorld task that outputs the message Hello MSBuild to the loggers attached to MSBuild. This is achieved by using an instance of the TaskLoggingHelper class. In this case, we have directly implemented the ITask interface. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required