tags:

views:

371

answers:

1

Hi,

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?

+3  A: 

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;
 }
}
madgnome