| Details |
![]() |
| QuickDocId | 565 |
| Written by | Imar Spaanjaars |
| Posted | 11/20/2011 16:54 |
| Page views | 5308 |
Are you looking to hire an experienced software developer or .NET consultant? Then get in touch with me through my company's web site at devierkoeden.com
Found an interesting article on this site? Got inspired by something you read here? Then consider making a donation with PayPal.
Over the past weeks I received a number of requests to explain how I typically set up my Visual Studio projects so they are easy to manage across a team that uses Team Foundation Server (TFS). I received another request from a client just this week and instead of helping him over the phone or paying him a visit and do it for him, I decided to write a quick document with instructions which eventually resulted in this article.
In this article you'll see how to create a multi-project solution in Visual Studio. I'll show you how you can use this structure to set up an ASP.NET MVC 3 application with a separate class library project for business logic and one or more unit test projects. However, you can use the exact same principles for other types of Visual Studio projects such as Web Forms, Win Forms, WCF and more. Over the past years, I found that this set up brings me the following benefits:
This is just my take at setting it up. If you find anything wrong, or have better alternatives to accomplish the same thing: feel free to speak up using the Comments section at the end of this article.
Without further ado, let's get started.
This document assumes a namespace convention for your projects and solutions of CustomerName.ProjectName.LayerOrAppName. The solution will be called CustomerName.ProjectName and each project then gets its own suffix explaining what it's used for. In this article I'll use CustomerName.ProjectName literally, but obviously you would substitute that for a real client and project name.
This Main folder is used later for Branching in TFS. (This all feels a bit clumsy but I see no other way to create the solution with this name and store it in a folder called SolutionName/Main. Fortunately, this is a one-time operation.)

Figure 7
With this setup, all your projects are located in sub folders of the Main folder that contains the Solution File. This in turn makes it easy to manage the solution from a TFS point of view because all references between the various projects and assemblies can be resolved relative to the main solution.
If you ever have the need to add new projects, just follow the exact same steps: add applications under the Applications folder and tests under the Tests folder. When another developer then gets a latest version of the solution from source control, the new projects are downloaded automatically as well. Obviously, in order for all this to work, you need to add the solution to Team Foundation Server Source Control first, which is the topic of the next section.

Figure 9
After some time, development on the Main branch can be ready for a release. In order to let developers continue work on the Main branch while you prepare the release, you should branch the application. For example, you can branch of “Beta 1” and release that.
Note: in this model I assume the Main branch is where continuous development takes place, while releases are branched off this main branch. If you use a different branching model this section does not apply directly, but the principles remain the same.
In order to create the branch, follow these steps:

Figure 11
You now have two separate branches of the same application. Long-term development goes on in the Main branch while you can make changes to Beta 1 necessary for the release. In addition, bugs you find in Beta 1 can be fixed there and propagated to the Main branch or vice versa.
If you want to work on the Beta 1 version, double-click its .sln file in the Solution Explorer. Then enter C:\Projects\ClientName.ProjectName\Beta1 as the path for the application so your two branches end up side-by-side on your disk. In addition, you may need to get a local copy of the Packages folder in order to get all of the third-party assemblies and other files.
Hope you find these instructions useful. And if you have improvements or alternatives: post them below using the comments feature!
Wonder where to go next?
You can read existing comments below
or you can post a comment yourself on this article
.
Consider making a donation
Please consider making a donation using PayPal. Your donation helps me to pay the bills so I can keep running Imar.Spaanjaars.Com, providing fresh content as often as possible.
I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article. The Talk Back feature is not meant for technical questions that are not directly related to this article. So, a post like "Hey, can you tell me how I can upload files to a MySQL database in PHP?" is likely to be removed. Also spam and unrealistic job offers will be deleted immediately.
When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you. It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button.
If you want to object to a comment made by another visitor, be sure to contact me and I'll look into it ASAP. Don't forget to mention the page link, or the QuickDocId of the document.
For more information about the Talk Back feature, check out this news item.
| QuickDocId | 565 |
| Full URL | http://imar.spaanjaars.com/565/recommendations-for-setting-up-a-visual-studio-solution-for-tfs |
| Short cut | http://imar.spaanjaars.com/565/ |
| Written by | Spaanjaars.Imar.Model.ContentSummary.CreateAuthorName |
| Date Posted | 11/20/2011 16:54 |