Upgrade Paths for Custom MSBuild Tasks

I’m regularly asked what’s the best way to upgrade an MSBuild-based build process to a Workflow Foundation-based build process and one of the most important parts of this is how to leverage the investment and dependence you have on any custom MBBuild tasks you’ve written. This post outlines four different ways you can make your custom MSBuild tasks callable from a Workflow Foundation workflow.
Use MSBuild Activity to call MSBuild wrapper around MSBuild task

Create a very simple MSBuild project with a single target that calls the MSBuild task.
Arguments are passed as properties to the MSBuild project which passes them to the MSBuild task. Complex properties (arrays, objects, etc.) need to be converted to strings to be passed as a property to the MSBuild project.

Pros:

No coding required.
Simple.
Leverages existing MSBuild knowledge.
No modifications to existing MSBuild task. Don’t even need access to it’s source.
Not much Workflow Foundation knowledge required.
MSBuild task can still be used from MSBuild.

Cons:

I’m not sure how you’d deal with output properties in this solution.
Limited debugging experience.
Limited testability.
Don’t have full access to the Workflow Runtime from MSBuild project or MSBuild task.
Not a simple drag drop experience to call the task from a workflow.

Wrap MSBuild task in a custom Workflow Activity

Create a custom workflow activity with the same properties as the custom MSBuild task.
Custom workflow activity instantiates a copy of the MSBuild task and proxies it’s properties through to the custom MSBuild task.
When the workflow activity is executed then it invokes Execute on the MSBuild task.

Pros:

Can deal with output properties.
Easier to deal with complex properties.
Improved debugging experience.
Improved testability.
Can access the Workflow Runtime in the wrapper.
No modifications to existing MSBuild task. Don’t even need access to it’s source.
Can still call the MSBuild task from MSBuild.
Simple drag drop experience to use the workflow activity from a workflow.

Cons:

Coding required.
Some infrastructure classes would be need to trick