Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Organizing a Visual Studio Solution with "Solution Folders"

When setting up a Visual Studio .NET solution with many projects, do you find "Solution Folders" useful? What are the drawbacks?

My original thought was that using Solution Folders can be useful to logically organize like projects within a solution. However, I was surprised to learn that a creating a Solution Folder does not create a corresponding Windows folder. From MSDN:

"Solution Folders are an organizational tool in Solution Explorer; corresponding Windows folders are not created. We recommend that you organize your projects on disk in the same way that you organize them in the solution."

I am considering organizing the solution so that every project is contained within a solution folder. Is this a good idea?

like image 447
YeahStu Avatar asked Jan 07 '09 19:01

YeahStu


2 Answers

Solution folders can help organizing your projects. And they have one big advantage: If you want to build some sets of projects then you can mark them and right-click them and select "Build selected projects". If your solution folder organization fits you can simply right-click on a solution folder and select "Build".

We have sln-folders for "MainApps" and "Test" (and some other). If you need all Apps, you build the complete solution. But if you don't want waiting for the Test projects to build you can simply right-click and build the "MainApps" folder!

like image 84
mmmmmmmm Avatar answered Nov 15 '22 23:11

mmmmmmmm


A solution is a collection of relevant projects, collected together to meet some purpose such as an application. The solution file (yes, it's an actual file, not a folder, although it appears like a folder in VS) itself is worth having a look inside - it's just metadata describing what the solution contains, most importantly its projects.

You can quite legitimately use the same projects in different solutions.

For instance, we have a WinForms application, that has projects such as:

  • BusinessObjects
  • DataAccess
  • EnvironmentSupport
  • CustomControls
  • MainUI (it's not actually called this, but that's what it is)

Building the solution builds the whole windows app.

Then we also have a web application - in its own solution. But since we reuse several of our projects, they make an appearance in the web solution as well, which has:

  • BusinessObjects
  • DataAccess
  • EnvironmentSupport
  • MainWebUI (again, it's not actually called this)
  • CustomWebControls

Again, building the solution builds the whole web site.

Our projects appear in source control only once, and it all works a treat.

The way we've structured it, a solution pretty much equates to an application, although this is only a loose relationship. We also have a Deployment solution for the windows application, which has all the WinForms app projects, plus the Setup project (which creates the .MSI). We keep it separate since it contains a lot of additional stuff that makes it quite large.

HTH.

like image 12
ChrisA Avatar answered Nov 15 '22 23:11

ChrisA