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

by Petr PruidzeMay 12, 2010
Find out how to overcome the issue of different assembly versions with the old names under the new TFS 2010 release.

The issue with TS 2010

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 blog post, we’d like to describe how our team elaborated on several ways to solve this problem.

 

Three solutions possible

We found three possible solutions:

  • On the 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.
  • Another option is to use reflections. This method is really good, but requires a great deal of time on implementation and testing.
  • 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.

 

Implementation

To start with, open Configuration Manager.

Create a new configuration that will be used for build-building other TFS version. We’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 we 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 our 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 our 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?

 

Further reading

 

About the author

Petr Pruidze is Lead .NET Architect at Altoros with more than 7 years of experience in MS .NET application development. Petr manages all the development and production-grade projects for the company’s customers, mentoring developers and ensuring the team follows efficient, effective, and quality code development principles.

 


The post was written by Petr Pruidze; edited by Inessa Bokhan and Alex Khizhniak.
Performance of Distributed TensorFlow
  •  
  •  
  •