Using Solution Folders


Menu:  Project -> Add New Solution Folder; [Right-Click Solution] -> Add -> New Solution Folder
Command:  Project.AddNewSolutionFolder
Versions:  2008,2010
Published:  3/27/2010
Code:  vstipProj0009

 


Did you know there are special folders to help you organize large solutions?  There is!  They are called, appropriately enough, Solution Folders.  To create one just Right-Click on your solution (or go to Project -> Add New Solution Folder) and you will see this in Solution Explorer:


image


 


Simply give the folder a name and you are good to go.  But so what?  I mean, what can you actually DO with these things?  Here is a list of stuff you can do:




  • Move or add projects to them. Solution Folders can be nested to create greater organizational structure.



  • Add, delete, or rename Solution Folders at any time, if the organizational requirements of the solution change.



  • Unload all projects in a Solution Folder to make them temporarily unavailable for building.



  • Collapse or hide entire Solution Folders so that you can work more easily in Solution Explorer. Hidden projects are built when you build the solution. 




  • Build or rebuild all the projects. The projects are built in the order specified by the project dependencies.


SPECIAL NOTE: 

Solution Folders are an organizational tool in Solution Explorer; corresponding Windows folders are not created.  Microsoft recommends that you organize your projects on disk in the same way that you organize them in the solution.  But that is your call 🙂

Comments (15)
  1. Terry says:

    I can not figure out how to add a policy file for the solution folder so I could turn off building for all projects in an ‘archive/review’ folder.  Am I missing something simple?

  2. zainnab says:

    Terry — I am looking into it now with the VS team and will update when I learn something. 🙂

  3. zainnab says:

    Okay, the official word is in and it is:

    That comment should not be there.  Policies were deprecated a long time ago and this is a documentation error.  

    I’ve updated the post to reflect the new information and thanks for the great catch Terry! 🙂

    Z

  4. Luc Cluitmans says:

    "Solution Folders are an organizational tool in Solution Explorer; corresponding Windows folders are not created.  Microsoft recommends that you organize your projects on disk in the same way that you organize them in the solution.  But that is your call 🙂 "

    Since I discovered solution folders a few months ago I have been using them intensively.

    One of the ways I use them however would conflict with the above advice (and I am therefore happy it is just advice, not enforced).

    Before I explain, let my emphasize that it is very well possible (and useful, IMHO) that a project can be placed in multiple solutions – right-click on a solution or solution folder and choose "Add|Existing project".

    I tend to have multiple solutions (all in the same directory) that wrap different subsets of the projects – one big solution wrapping all projects, and then some smaller solutions that only wrap a subset of related projects from that "master solution".

    The point here is: the way I structure those projects in solution folders tends to be different in different solutions. For instance in a solution whose main purpose is to develop some utility library, that utility library would be at the root, outside any solution folders (and some test related projects for that library would be in the same solution but in a ‘tests’ solution folder). In contrast, another solution that *uses* that same library would also contain that library project (but not the tests), but in a solution folder named ‘libraries’. And the "master solution" would contain that same library project, but in a solution folder named after that library.

    If solution folder names were tied to physical disk folders this would not be possible.

  5. chad says:

    Has this been disabled in 2010? Or perhaps just disabled in the C++ Express version that I’m using.

  6. jjackk says:

    how to delete the thing i created by mistake?

  7. zainnab says:

    Just right-click and select "Remove" to get rid of folders you don't want 🙂

  8. Marc says:

    This is a nice start, but if the recommendation from the toolmaker is that the tool be used in a given way (physical == logical) then why isn't a default for that even an optional facet of this feature?

  9. xeno says:

    Hey I cannot see the folder structures in my solution explorer, even though they exist in my source control system

  10. zainnab says:

    Xeno,

    The folder structures in Solution Explorer are not physical ones, just logical ones.  Also, they are stored in the.SUO file which is unique to each person in Visual Studio.  The point of Solution Folders is so you can organize items the way YOU want without having to be bound by any physical constructs.  Hope this helps 🙂

    Z

  11. Chris Walsh says:

    "Also, they are stored in the.SUO file which is unique to each person in Visual Studio.  The point of Solution Folders is so you can organize items the way YOU want without having to be bound by any physical constructs."

    1) So if I delete my .suo file, all projects revert back to the root of the solution?

    2) Also, does reorganising projects in Solution Folders have any (adverse) impact on TFS Source Control?

    Thanks for your intro into Solution Folders! 🙂

  12. Fernando says:

    I am new to solution folders, and programming in general.  How would I open a form in my master solution that resides on one of the solution folders?

    For Example:

    on a button's handler I would write:

    Dim aSecondSolutionForm as SecondSolutionForm

    aSecondSolutionForm.ShowDialog()

  13. zainnab says:

    Fernando,

    Solution Folders are logical constructs that exist in Solution Explorer only and have no impact on the physical location of files.  They are just a way to organize things in Solution Explorer.  Just access your forms as you normally would 🙂

    Z

  14. zainnab says:

    Chris,

    Looks like i missed you questions let me address them real quick:

    1. Yes, theoretically although the SUO information is stored in other areas as well so it may just regenerate the SUO instead.  I haven't found out where these other areas are (or even if they are areas or just one place) but have tried to delete my SUO only to have it regen when I opened the solution again.

    2. Nope.  Zero impact to anything except how you view the information in Solution Explorer.  🙂

    Z

  15. Emanuel Jimenez says:

    Hey I cannot see the folder structures in my solution explorer, even though they exist in my source control system. I I have the same problem HELPPPPP . Thansk from Argentina

Comments are closed.

Skip to main content