MSBuild and Workflow Foundation
January 4, 2011 Leave a comment
I am in the process of investigating how to create a FTP Task to be used in the TFS Build Engine. This post is about creating a MSBuild task, kicking it off, and then integrating WF into that task.
Using this MSDN article, I crated a basic task like so:
using System; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; namespace Tff.FtpTask { public class PublishWebsite: Task { public override bool Execute() { return true; } } }
I then created a build file like so:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="PublishWebsite"> <PublishWebsite /> </Target> </Project>
When I ran it:
The build file is not finding the task I created. I altered the build file like this:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <UsingTask TaskName="PublishWebsite" AssemblyFile="C:\Users\Jamie\Documents\Visual Studio 2010\Projects\Tff.FtpTask\Tff.FtpTask\bin\Debug\Tff.FtpTask.dll" /> <Target Name="PublishWebsite"> <PublishWebsite /> </Target> </Project>
And pop goes the fire cracker:
I then added in a workflow to the project:
Called the workflow:
public override bool Execute() { WorkflowInvoker.Invoke(new PublishWebsite()); return true; }
And Bang! That was pretty straight forward.