TFS – Creating Development and Release folders

Creating a TFS (Team Foundation System) folder structure is a very crucial step for a correct development and deployment strategy. In this post I am going to share with you how a TFS project structure should look like. Also in the end we will see some best practices when working with TFS.

Introduction to TFS

TFS i.e. Team Foundation Server is a versioning and project management tool from Microsoft and is used by many organizations mostly as a code repository. TFS is the on premise version. Also the latest version is called as Azure DevOps and is a cloud based versioning, management and deployment tool. More info at
https://azure.microsoft.com/en-in/services/devops/

In this post, we will be focusing on TFS and not on the DevOps version.

TFS Server and Team Projects

TFS consists of two components; the first is the server where TFS server software would be installed. This server will be the actual place where files will be physically located along with all the various contents. Another feature of this server software is that we can create Team Projects. They are nothing but a logical grouping of a particular project. We can add / delete members to this team project. Also we can create groups of members and these groups can be given various permissions on a particular team project. In this way you can manage security on any particular project and we can have multiple projects within one team project.

TFS Client

Coming to the client side of TFS, usually Visual Studio has a lot of built in features for viewing TFS from the VS IDE. Open VS 2019, click on Team -> Manage Connections

Image for TFS connection

To connect to a TFS, sign in with the credentials given by your TFS admin. Once the authentication is done based on the access rights we will be able to see all the team projects from that TFS server as shown below

Workspaces

The first step will be to map the TFS server folders to our local machine folders. This is called as a workspace. A workspace is nothing but a mapping which shows in which local folder will the server files will be downloaded. In short we will be always working with a local copy of a project at any given point of time. Once the mapping is done, the first step is to ‘Get-Latest’ the project source code. Get latest is the process which will download the most updated server files to our local machine.

More details on how to connect to TFS
https://docs.microsoft.com/en-us/visualstudio/ide/connect-team-project?view=vs-2019

TFS folder structure – Creating Dev, QA, UAT and Production branches

Just like a tree view, the TFS structure will consist of a root folder which can be converted to a root branch. This root branch will be the starting point of any project development. Based on the project iteration (stage/cycle/sprint) we can name this branch as Project_Dev_Feature, Project_Dev_Version, Project_Dev_Iteration_1 etc. We can then start development on this branch. Once the unit testing is done you can create a new branch from this branch for Staging/QA as Project_QA_<<>>. We can name this branch accordingly. Once the QA cycle starts all the bug fixes will be done in this branch and after QA sign-off is received you will create another branch from this QA branch and name it as UAT Project_UAT_<<>>. After UAT sign-off, we will create another branch called as production branch Project_Prod_<<>> and this production branch will be deployed to the production environment. In short the UAT and production branches are identical at this point in time.

TFS folder structure – Creating Post Production branches

Once the production branch is live, we can rename or label it as a stable version. We will not be touching this stable version anytime now. Next we will create another branch from the production and name it as ‘Project_Post_Production_<<>>’. Note that we will have to maintain any naming conventions throughout this process. It is in this branch that all post production issues/bugs will be fixed.

New development / enhancements

Remember the Project_Prod_<<>> branch created for production deployment. In this branch, we will be working on the next development / enhancements. But in order to make sure that you also factor in the production fixes done in the post production branch, we will have to backward merge all the changes from post production branch here. This will ensure that we will be deploying all new changes along with the earlier post production fixes as well. Once this is done, this branch will undergo the same process as QA, UAT and production. Note that we can always rename or create a new branch from any existing branch based on our scenario.

TFS Best Practices

  1. You should always closely replicate the SDLC life cycle followed in your organization in your TFS folder structure. For e.g. If you are following agile methodology then it would not make any sense to create a structure as Project_Dev_Iteration_1 since this resembles a kind of waterfall model.
  2. Never check in bin, obj folders. These folders are always dynamic in nature hence you can choose to exclude them in the TFS structure. More details can be found at
    https://docs.microsoft.com/en-us/azure/devops/repos/tfvc/add-files-server?view=azure-devops&viewFallbackFrom=vsts#tfignore
  3. For any third-party DLLs or software, always include a DLL folder in the TFS structure outside your project so that nobody includes their own independently downloaded dlls. This can be a headache if all developers keep on adding different dlls versions and keep them checking in which can result in project build errors due to version mismatch.
  4. In order to add existing items from your local mapped workspace to your TFS folder, there is an option called ‘Add Existing Items’. Using this feature, you can add local files to the TFS folder and also selectively filter out certain file types.
  5. There is a setting in TFS which allows only one person to check out a file at any given point in time. Enabling this setting ensures that no two developers check out and work on the same file.
  6. Do not allow delete branch permissions to any members since this can be catastrophic.
  7. Most of the problems with developers getting incorrect versions of files are due to the fact that they do not make code check-in a habit. All compiled code should always be checked in. Before any developer starts working on any code, they should first do a ‘Get Latest’ first so that they get the updated code. There is also a setting which forces a ‘Get Latest’ on a file if someone tries to do a check-out on that file.
  8. TFS can also be used for creating work items, bug tracking, analysis and more. Work items can be linked to tasks with individual effort hours, linking tasks to bugs, code fixes, reviews, etc.

Summary

TFS allows source code management requirements, project management, automated builds and release management capabilities. It easily integrates with IDEs like Microsoft Visual Studio. Team Foundation Server has 2 versions one is on-premises and one is online. The online one is called Azure DevOps which is on Microsoft’s cloud platform. Azure DevOps requires no setup. A user can start by signing in using a Microsoft account to set up an environment, creating projects and adding team members.

Hitesh Boricha

I have a little over a decade experience in the IT industry. Having worked in various roles in this industry, I am passionate about technology.

Leave a Reply

Your email address will not be published. Required fields are marked *

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