Chapter 1, Master Projects and Solutions
#3 Organize Projects and Solutions
The problem with this structure is that it is not easy to work with since the
solution file is nested inside one of the project directories and references a
project file that is contained in a different directory. If you were to move
Folder A to a different location, the solution would end up with a broken ref-
erence to Project File B. A better way to handle solution files is to always start
with a blank solution and then add project files to this solution over time. To
start with a blank solution, you simply need to click on File
New Blank
Solution. You can create a directory for this blank solution and add projects
to this solution. Your file structure will now look more like this:
Solution Directory\
Solution File
Folder A\
Project File A
Folder B\
Project File B
This file structure is much more manageable. You can check the entire solu-
tion into SourceSafe, you can safely move the solution directory, and you
can even zip up the entire directory structure.
Working with Multiple Solutions
Whenever possible, you should stick to a single solution for your develop-
ment project. But when you get above a certain number of projects in a solu-
tion, it starts to become unwieldy for you to manage. It is also inconvenient
to have multiple executables or web projects in a single solution, as you will
constantly be switching the startup project when you want to run or debug
one of the other executables. There are a number of different strategies for
working with multiple solutions:
Partitioned solutions under a master solution
Often, the number of projects in a solution becomes cumbersome and
you need a new method of organization. The best way to deal with this
is to create multiple subsolutions that contain the projects for a small
section of the overall solution and keep a master solution that contains
all of the projects. The reason this is possible is that projects can belong
to any number of solutions, whereas solutions cannot belong to other
solutions. Figure 1-13 shows an example of partitioned solutions with a
master solution file.
This method of solution division is ideal when working with large
projects because individual developers can work with a more manage-
able subset of projects. A master solution still exists that can be used by
the build process and source control. This organization also allows you
to continue to use project references, which are preferable to assembly
[Hack #2].
Organize Projects and Solutions #3
Chapter 1, Master Projects and Solutions
Partitioned solutions without a master
You can also divide development projects into different solutions with-
out using a master solution. The disadvantage of this method is that you
won’t have one place to build your project from. Figure 1-14 shows an
example of partitioned solutions without the use of a master solution
Figure 1-13. Partitioned solutions with master solution
Figure 1-14. Partitioned solutions without master solution file
Master Solution
Project A
Project D
Project F
Project B
Project C
Solution BSolution A
Project A
Project B Project C
Project D
Project E
Project C

Get Visual Studio Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.