TFS build process – Activity “CopyFile” must be used in the context of an AgentScope

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!

Advertisements
  1. #1 by spatricios on October 11, 2011 - 6:26 pm

    That work fine to me!

    Thanks for sharing your experience!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: