My task was to create an Activity object to perform some business logic during a build in TFS. While creating this Activity (using the CodeActivity template), I encountered two problems.
First, my custom activities wouldn’t work after I went through the long process of registering them properly for the TFS build process to use them, which I’ll be detailing in depth in a post later this week.
What I mean by wouldn’t work is that I would run my build, it would run successfully, but the expected action – in this case, copying a file to a remote share – wouldn’t occur. No errors, no file, nothing.
After lots of troubleshooting and several hours of research, I thought that maybe it was because my Activity was in the wrong location in the build template. I moved it to the top of the template, and my build failed with this message:
Activity “CopyFile” must be used in the context of an AgentScope.
Ah, an actual, honest-to-goodness hint of what the problem could be. I moved the Activity to a location inside a “Run On Agent” process, then ran the build again. Success! The build worked and the file was copied.
So the lesson is, if you are modifying your Team Foundation Server build process by adding a custom Activity, make sure you put the Activity in the right spot!