How To: Create Your Source Tree in Visual Studio Team Foundation Server

patterns & practices Developer Center

Team Development with Visual Studio Team Foundation Server

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

J.D. Meier, Jason Taylor, Prashant Bansode, Alex Mackman, and Kevin Jones
Microsoft Corporation

September 2007

Applies To

  • Microsoft® Visual Studio® 2005 Team Foundation Server (TFS)
  • Microsoft Visual Studio Team System


This How To article walks you through the process of creating a new source code tree structure in TFS. The purpose of this How To article is to familiarize you with the end-to-end steps required to create your source tree.


  • Objectives
  • Overview
  • Summary of Steps
  • Step 1 – Create a new team project.
  • Step 2 – Create a workspace mapping
  • Step 3 – Create your folder structure in Source Control
  • Step 4 – Add your source to your source tree
  • Additional Resources


  • Learn how to create a new team project
  • Learn how to create a workspace mapping
  • Learn how to create a source tree in Team Foundation Server source control


Although you can quickly add a solution to source control by right-clicking your solution in Solution Explorer and then clicking Add Solution To Source Control, this option does not enable you to explicitly set up your source tree structure in source control. By explicitly defining your source tree structure in source control, you can arrange your source beneath top-level folders and use separate top-level folders to contain your main source base and your branched source base such as the branches you might use during development or to maintain production releases.

In this how to you will see the steps required to explicitly create a source control tree structure.

Summary of Steps

  • Step 1 – Create a new team project
  • Step 2 – Create a workspace mapping
  • Step 3 – Create your folder structure in Source Control
  • Step 4 – Add your source code to your source tree

Step 1 – Create a New Team Project

In this initial step, you create a new team project with default settings.

  1. In Team Explorer, right-click your TFS server and click New Team Project…
  2. In the New Team Project dialog box, type a project name such as MyTeamProject1 and then click Next.
  3. On the Select a Process Template page, leave the default MSF for Agile Software Development - v4.0 and then click Next.
  4. On the Specify the Settings for the Project Portal page, leave the team project portal name as MyTeamProject1 enter a description for the team project portal and then click Next.
  5. On the Specify Source Control Settings page, leave the default option Create an empty source control folder selected and then click Next.
  6. Click Finish to create the project.

A new team project is created on your TFS server, using the selected process template with an empty source control node.

Step 2 – Create a Workspace Mapping

In this step you create a workspace mapping to define the mapping between the folder structure on the TFS server and client. You need to do this in order to create a source tree structure. First, the source tree structure is created in your workspace. You then need to perform a check-in to your TFS server.

You can create a workspace mapping in one of two ways:

  • Set the workspace mapping explicitly
  • Perform a get operation on your team project.

To set a workspace mapping explicitly

  1. In Visual Studio, on the File menu, point to Source Control and then click Workspaces.
  2. In the Manage Workspaces dialog box, select your computer name and then click Edit.
  3. In the Edit Workspace dialog box, in the Working folders list, click Click here to enter a new working folder.
  4. Click the ellipsis button, select your team project (for example MyTeamProject1), and then click OK.
  5. Click the Local folder cell to display another ellipsis button.
  6. Click the ellipsis button beneath Local Folder and then browse to and select the local folder on your development computer where you want to locate your team project workspace; for example C:\DevProjects\MyTeamProject1.
  7. Click OK twice to close the Edit Workspace dialog box.
  8. Click OK in response to the Microsoft Visual Studio message box that informs you than one or more working folders have changed.
  9. Click Close to close the ManageWorkspaces dialog box.

To perform a Get operation on your team project

  1. In Team Explorer, expand your MyTeamProject1 team project node.
  2. Double-click Source Control beneath your team project.
  3. In Source Control Explorer, right-click the root folder MyTeamProject1 and then click Get Latest Version.
  4. In the Browse For Folder dialog box select your local path (for example C:\DevProjects\MyTeamProject1) and then click OK. This maps the team project root folder within TFS to a local path on your computer.

Step 3 – Create Your Folder Structure in Source Control

In this step, depending on your strategy and project requirements you create a source control folder structure on your server. This should generally start with a /Main/Source folder structure, which enables you to subsequently create Development and Releases branches at the same level as Main. For example, the Releases folder would be used to contain branched code corresponding to the software releases that you are maintaining. The Development folder contains your isolated development branch.



                    /MyApp1                                             à Contains MyApp1.sln

                                /Source                                    à Container folder

                                            /ClassLibrary1             à Contains ClassLibrary1.csproj

                                            /MyApp1Web              à Contains Default.aspx

                                /UnitTests                               à Contains unit test projects

                                            /ClassLibrary1Tests    à Test project for ClassLibrary1

                                            /MyApp1WebTests     à Test project for MyApp1Web

        /Build                                                              à Contains build output (binaries)

        /Docs                                                               à Contains design docs etc

        /TestCases                                                      à Contains test case documentation





















        /Release 1.1

        /Release 1.2

To create a folder structure on the server:

  1. In Team Explorer, expand your MyTeamProject1 team project node.
  2. Double-click Source Control beneath your team project.
  3. In Source Control Explorer, select the root node, right-click in the Local Path: pane, and then click New Folder.
  4. Type the name Main and then press ENTER.
  5. Create a Source folder beneath Main.
  6. Repeat the previous steps to create any other root folders you might need including Development and Releases folders.
  7. After you have created your tree structure, right-click the MyTeamProject1 root node in Source Control Explorer and then click Check-in Pending Changes.
  8. In the Check In - Source Files – Workspace dialog box, select the folders you need to check-in, add a comment, and then click Check In. This builds your local folder structure and adds the structure to TFS source control.

Step 4 – Add Your Source Code to Your Source Tree

In this step, you add source code from your local drive to your source control tree on the server. In this example, you create a new Web application and class library project and add these to source control.

To create a new Visual Studio solution file:

  1. On the File menu, point to New, and then click Project.
  2. Expand Other Project Types and then click Visual Studio Solutions.
  3. In the Templates pane, select Blank Solution.
  4. Type MyApp1 in the Name text box and C:\DevProjects\MyTeamProject1\Main\Source into the Location text box.
  5. Click OK.

Visual Studio creates your new solution and places the solution (.sln) file in the C:\DevProjects\ MyTeamProject1\Main\Source\MyApp1 folder.

To add a new Web site to your solution:

  1. In Solution Explorer, right-click your solution, point to Add, and then click New Web Site.
  2. Select ASP.NET Web Site from the Templates list, File System as the Location and C:\DevProjects\MyTeamProject1\Main\Source\MyApp1\Source\MyApp1Web as the path.
  3. Click OK. Visual Studio creates the Web site.

To add a new class library project to your solution:

  1. In Solution Explorer, right-click your solution, point to Add, and then click New Project.
  2. Select Visual C# from the Project types list, and Class Library from the Templates list.
  3. Leave the name as ClassLibrary1 and set the Location to C:\DevProjects\MyTeamProject1\Main\Source\MyApp1\Source.
  4. Click OK.

Visual Studio creates the new project structure. Your local file structure should now look like the following:


To add your solution to source control:

In Solution Explorer, right-click your solution and then click Add Solution To Source Control Your solution and two projects are added to Team Foundation Source Control.

Your source control tree structure now should look like the following:


Additional Resources

patterns & practices Developer Center