Dependency Replication in TFS 2010

I’m not sure exactly how many people do this, but it seems like there isn’t much documentation out there on how to do this exactly. So after lots of trial and error I’ve finally gotten dll replication to work for our TFS environment.

So, first i’ll go over the general overview of what needs to be done to enable TFS to replicate files during a build. Just a reminder, this is for TFS 2010, not any previous version of TFS.

1) You’ll need a custom build template
2) You’ll need a custom TFS Activity

Second, I’ll let you know i basically followed the tutorials by Ewald Hofman and then modified things to work the way I needed them to.

So our scenario is that we have multiple products that use dll’s from a core product. When that core product gets changed, we don’t want to have to copy the dll’s manually from the build location to the locations needed by the other products. Each one of our products have a folder called SharedBinaries, this is where those dll’s live.

Now the question is, how do we do this? If you’re using TFS 2008 or 2005, you can easily just acquire TFS Dependency Replicator, it will handle all that for you. For TFS 2010 however, this doesn’t work anymore. Or more precisely, I was unable to get it to work. So, time to learn how to use Windows Workflow. At first this seems very daunting, but after you take it a bit at a time, things start to make sense.

I would highly recommend you take a look at the tutorials i mentioned earlier, they will give you a good base to work from. And if i were to go through and document the whole process here, i would feel like i’m plagiarizing someone else’s work. Go at least as far as Part 4 – Creating your own activity, this is where i’ll start my documentation.

I created a new Code Activity and called it ‘ReplicateFiles.cs’.  You can download it here.

You’ll want to add three Arguments to your custom template.


In the Metadata Argument, you’ll want to add those three Arguments as required fields.

In the custom template, I added the custom activity just before the gated check-in process.

Lastly, you’ll want to add the three Arguments into the appropriate fields on the custom activity properties, as well as specifying the BinariesDirectory as the SourceLocation to copy the files from.

While setting up your build, you’ll want to make sure you fill out those newly required fields in Build Editor Process Section.

Before you go wild and start running builds, go through this checklist.

  • Does your build controller know the path to the custom binaries you’ve made (for the custom build activity).  (reference)
  • Have you checked in the latest version of your custom template, as well as the custom activity dll
  • The required arguments in the ReplicateFiles.cs are what you pass into the class from the custom template you’ve created, make sure those are filled out in the build template.
  • Make sure you have the correct path to your TFS server for tfsName in ReplicateFiles.cs.
  • Make sure that the user you run your build service under has file system permissions for the location where you want to create your temporary workspaces.
  • I had this issue, and it almost drove me nuts! I kept getting access denied errors when trying to overwrite the files in the target branches. Make sure that the files being replicated ARE NOT checked out and locked!

If you have any corrections, feedback, or ideas! Please comment and let me know!

Published by Dan

I'm a technophile at heart. I love tech and how it can make our lives better. Let's take a little trip into my mind :P

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.