FTP Task in WF and TFS

Now that I have custom MSBuild tasks working using WF (and kicking them off using TFS), I realized that I DON”T want to use custom MSBuild tasks. It seems easier just to put in a custom WF task as part of the bdefult build template that comes out of the box in TFS. To that end, I created a new template and identified the step where I would put in this new workflow task (it took 5 minutes to click through this TFS WF, it is a beast!):

I then created a new project to get the FTP tasks working. Before using WF, I thought of just creating a Console app that does what I want. I monkeyed around with the the native .NET FTP library but is stinks and then I tried FTPLibrary – which didn’t work out of the box. I then tried EditFTP and it worked great so I used that. I created a structured program that uses the Edit FTP API to copy the contents from the build directory to the FTP site (oooh, recursion):

Pretty simple stuff – note the use of ChangingWorkingDirectoryUp to keep the current directory on the remote site synched.

I then thought about how to create a WF class that does the same thing. To do that, I fired up a VS2010 Activity diagram. My 1st cut was WAAY too complicated:

I refined it based on the fact that my FTP API automagically overwrites files:

Much easier. I then created a workflow activity (with its .asmx extension). I realized that I would simply throw a code activity on to the designer, move the procedureal code I already wrote into that activity, and call it a a day. However, I wanted to see if I can exploit the power of WF and replicate the activity diagram using workflow tasks. I’ll document my experiences with that attempt next week.