4

I have written a custom MSBuild task, call it TaskA, that parses a file and does some processing on it. I now want to write another MSBUild task, call it TaskB, that uses TaskA within it. I know that I could use TaskA like a normal class and just call its execute method from TaskB. But do you think that this is plausible? Will the log messages from TaskA still be logged when TaskB is being executed?

1 Answer 1

7

Yes it is plausible, and yes the log messages from TaskA will still be logged. Don't forget to set the taskA.BuildEngine to taskB one.

public class TaskA : Task
{
    public override bool Execute()
    {
        Log.LogMessage("Task A");

        return true;
    }
}

public class TaskB : Task
{
    public override bool Execute()
    {
        Log.LogMessage("Task B");

        TaskA taskA = new TaskA();
        taskA.BuildEngine = BuildEngine;

        taskA.Execute();

        return true;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.