Thursday, March 17, 2011

Building Visual Studio Solutions Out of the Box

It is terrible when you are a developer at a new place and you open Visual Studio the first time, connect to your favorite source control like TFS or SVN, and open the desired solution, click build only to see many compile errors like invalid references.

Avoid creating this situation now by organizing your solutions so that they can easily be opened and built by new people.  You need to take into consideration how your solution is layed out, where external dependencies are, and how you present external tools.

First thing you need to do is make sure you solution file is at the root of all your projects.  If your all your projects are under c:/source, like in c:/source/MovieApp, then your solution should reside in c:/source.  You want to do this because it is not good practice to have a project reach up to a parent directory of the solution file into another branch for a referenced file or project.

Your structure should look like this:

Your next consideration needs to be references to external dependencies.  It is best if you have one location for this, right off the solution folder.  I usually call mine “External Dependencies”.  Then what you need to do is create an External Dependencies folder in the Visual Studio Solution and add your files from your “External Dependences” folder.  Now, whenever you reference a dll that is external, you use those files, and it will be gotten when you have a new developer get latest!  Easy enough.

Next thing is to provide all your external tools in your solution.  I cannot tell you the number of times I had to go find an exact version of a tool because of some quirk that version had but no others did.  Check it in with your source, don’t store it on a shared network drive.  Update it?  Great, update it in your source control.

Last tip is do not set your output directories to the same folder!  Never do this, please.  Ever.  Leave them in bin.  If you are doing this, you most likely have an external dependency problem in one of your projects.  Fix that.

No comments:

Post a Comment