Blog

Resolving a TFS 2010 Issue: The Same Names for Different Assemblies

Petr Pruidze

The issue

One of our projects utilized Team Foundation Server assemblies, and the need to use both TFS 2008 and TFS 2010 assemblies aroused when TFS 2010 was released. In short, the names of the assemblies stayed the same, while their versions were different. In this post, I’d like to describe how our team elaborated on several ways to solve this problem.

The solutions

1. On one hand, we could have created two different branches for the project—each branch for each version of assemblies. However, we’d had to support both branches in this case, which is not a great idea.

2. Another option is to use reflections. This method is really good, but requires a great deal of time on implementation and testing.

3. So, we decided to compile the project for different versions of assemblies, depending on the chosen “Solution Configuration” option. Let’s have a deeper insight into this option, since it appears to be the best way to solve the issue. Below is a step-by-step guide on implementing the solution. I hope it will help you, too.

To start with, open Configuration Manager.

Create a new configuration that will be used for build-building other TFS version. I’ve named the new configuration as “BuildRelease2010.”

As you may see, there’s no need to create a new configuration for each project in your solution. You may do this only in case your project utilizes different versions of assemblies—just like I had.

Open the properties of the projects that are supposed to be built with different versions of assemblies. Add “Conditional compilation symbols” to the new configuration.

Open the code itself and add the condition for working with different assemblies, if needed. In my case, the creation of the instance that implements the IserviceProvider interface required working with different versions of assemblies.

#if BUILD_RELEASE_2010
TfsTeamProjectCollection server = newTfsTeamProjectCollection(newUri(tfsUrl));
#else
TeamFoundationServer server = TeamFoundationServerFactory.GetServer(tfsUrl);
#endif

Open the .cproj file in Notepad or any other text editor, find the Reference to your assembly (in my case, it was Microsoft.TeamFoundation.dll), and add the following Condition tag: (Condition=”‘$(Configuration)’!=’BuildRelease2010′”).
..\Bin\TFS\Microsoft.TeamFoundation.dll

Now add the Reference to the new version assembly with the opposite Condition:
..\Bin\TFS2010\Microsoft.TeamFoundation.Client.dll

That’s it. Choose the configuration needed and start build-building, voila!

Cons

The look is not as preppy as it could have been. 🙂

Pros

Implementation is fast and easy.

If you had the same issue, how did you solve it?

No Comments

Benchmarks and Research

Subscribe to new posts

Get new posts right in your inbox!