When you are working on a complex application, it is possible that your solution will include a large number of projects. This can make it more difficult to navigate the code and quickly switch to the correct project. In some scenarios you can simplify this navigation using solution folders.
A solution folder is a container for one or more related projects. You can create many folders within a Visual Studio solution, including nested folders. They appear in the Solution Explorer as expandable and collapsible sections. For example, the image below shows a relatively simple solution where the projects are organised into folders for user interfaces, shared code and automated tests.
Although solution folders group projects in a similar manner to the way in which directories hold files, they are not stored as physical folders on disk. They are virtual folders that are only understood by Visual Studio.
Creating Solution Folders
It is a simple task to create a new solution folder. To create a folder within the solution, right-click the solution name in the Solution Explorer pane and choose "Add", then "New Solution Folder" from the context-sensitive menu. To create a subfolder, start by right-clicking an existing solution folder and then choose the same menu options. When the folder appears, type in a new name. You can also create solution folders using options from the Project menu.
To remove a solution folder, right-click it and choose the "Remove" option, or select it and use the "Project" menu or the Delete key. The folder, its subfolders and any contained projects are removed from the solution. The projects are not deleted from the disk, so can be re-added later, if required.
Adding Projects to a Solution Folder
Once you have a solution folder, you can create projects within it directly by right-clicking it and choosing the usual menu options. To move an existing project, either cut and paste it using the menus or simply drag the project over the folder in the Solution Explorer. You can drag projects out of a folder and drop them on the solution name to move them back to the root position.
Hiding Solution Folders
Another useful feature is the ability to temporarily hide a solution folder. This can help when you are working with projects that you rarely edit. To hide a folder, right-click it and choose "Hide". The folder and all of its projects will disappear from the Solution Explorer but will remain present in the solution.
If you wish to show the hidden folders, right-click the solution, or the parent folder of the hidden items, and choose the "Unhide Folders" option. This, and the Hide feature, can also be found in the Project menu.
29 January 2016