One of the problems I have found with creating a build server for our companies projects is that each individual project has several references to toolkits or controls that need to be installed separately; this would lead to me having to install several extra programs onto the server to get the builds working. The point of the build server is to ensure that the project compiles on a clean machine, having to install components to make the build work violates that objective.
The solution therefore is to add the references locally to each project. It also means that we keep everything that is required for a build together and under source code control. We then know which version of the references go with which builds, so if anything breaks we can work out what has changed. Everything required to produce a build should be under version control of some sort if you want to have reliable builds to give to clients.
When adding the references locally, firstly work out which of the references need to be moved. Some of them are obviously part of the .NET framework so there is no point adding them to the local repository as the Framework has to be installed anyway for the application to run. We also use Crystal Reports which has to be installed on the clients machine so we do not need to move those either. The remaining references are the ones that we will need, note the locations on the hard drive so you can move them locally later on:
With the references located, add a folder to Visual Studio, Right-Click on the project and then Add->New Folder, call it References or anything you like:
With the folder added, using Windows Explorer to move the references into the newly created folder within the project folder on your hard drive. Then add the references to the Visual Studio project via the Add->Existing Item menu (Note: I am adding additional references at this point as the project I am updating is also being converted to use the Microsoft Enterprise Library for the Exception Handling which is what the additional files are for):
You should then have something like this in your project:
With the files added to the project, delete the old references and re-add the files from their new location. Do this for all projects within the solution:
A point to note here is that if you have multiple projects within your solution it is OK to just have the references located in one of the projects, for example the main project, and then sub-projects reference the files from within the main projects folder.
For a practical example, consider the project I am working on here. It consists of 4 projects within the solution, there is the main .exe project, there is also a project containing the data access layer along with another project that has controls that are unique to this product and the final project contains controls that are common to all of our products. With this kind of arrangement I have placed the References folder in the .exe project, the data access layer and the custom app controls then reference the files held there in their own projects, these projects are only ever going to be in the same solution together and will always be built at the same time, so “should” never have to have a local copy within their own folder structure. The common controls project has its own References folder within its own folder structure as this project can be built on its own or as part of a number of other solutions. When I get the chance I will either take some more screen shots or draw a quick diagram to illustrate this.
You may also need to import the namespaces once they are added depending on if you strongly type your classes or not.
The screenshots are from Visual Studio 2008, but this should also work without a hitch on 2005 too.