Structuring Projects for Team Foundation Server

I've seen a few customers asking how to structure projects for Team Foundation Server.  I don't blame them.  Finding a structure that works well for you can be tricky, particularly if you don't have the benefit of hind-sight or a bunch of reference examples to draw from.

My team spent some time this past week evaluating various approaches and lessons learned from various projects  We boiled it down to something that seems to be working well, and distills what's worked for some teams.  With the caveat that we're still evaluating, here's what we learned ...

Solution
Local File System

 C:\MyApp
 \MyApp.sln
  \Source
     \MyAppWeb
       \ClassLibrary1

Source Control (Team Foundation Server)

 /Main
   /Build
  /Docs
   /Source
     /MyApp
          MyApp.sln
           /Source
             /MyAppWeb
               /ClassLibrary1
          /UnitTests
              /MyAppWebTests
              /ClassLibrary1Tests
 /Tests

Key points
Here's a few highlights about this approach:

  • On the client side, we explicitly creat our solution file up front instead of rely on defaults
  • The project folder containts one master solution. 
  • The project has source and unit tests.  Loading the solution for the project, loads the source and unit tests
  • The Main folder in TFS holds the project assets (Build, Docs, Source, Tests).  Using Main lets us create other folders for potential branches (Development, Production, Maintenance ... etc.)

Repro Steps
Here's a brief walkthrough to test using a file-based Web:

  1. Create a blank solution in VSTS
  2. Create a source folder on the file system (C:\MyApp\Source)
  3. Add new Web project (C:\MyApp\Source\MyAppWeb)
  4. Add new Class Library (C:\MyApp\Source\ClassLibrary1)

Verify your folder structure on your File System:

 C:\MyApp
    \MyApp.sln
  \Source
     \MyAppWeb
       \ClassLibrary1

Adding to TFS

  1. Add your solution to source control
  2. Create a Main folder
  3. Create a Source folder beneath Main

Verify your folder structure in Source Control Explorer

 /Main
   /Source
     /MyApp
          /MyApp.sln
          /Source
             /MyAppWeb
               /ClassLibrary1

More Information
You should know that while I talked through the single solution scenario, there are additional patterns.  Here's the key patterns we see:

  1. Single solution
  2. Partitioned single solution
  3. Multi-solution

You can find more on these patterns at Team Development with Visual Studio .NET and Visual SourceSafe.  You should also know that we have a few How Tos on structuring your projects coming your way.  We'll post them to our VSTS Guidance Project.

Share Your Story
If you've got lessons learned the hard way or practices to share, I'd like to hear them.   Now's a great time to share since we're actively building guidance.  Either comment here or write a post and leave a link.