views:

3162

answers:

9

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?

A: 

I don't know about solution folders, but inside of a project, you can use folders to organize source files together in a logical way, and THOSE seem to carry over to the file system just fine.

GWLlosa
If you preface an answer with the phrase "I don't know about [the topic asked about]," then you probably shouldn't post your answer.
Robert S.
I felt that the information I _did_ possess was relevant to the general issue being discussed by the problem, if not the exact problem. /shrug
GWLlosa
We're an ornery bunch.
Robert S.
No I think there's a valid point here (if badly put): why should solution folders behave so differently to project folders? Surely consistency would be better (or at least less confusing).It presumably all comes down to the fact that projects can be re-used amongst different solutions, each of which might have a different base directory, so their relative 'solution folder' would have to be different in each case. But that doesn't seem so hard to me.
piers7
+3  A: 

No, you should put all related project in a single solution. If you happen to have references to another solution and want to have access to its source then you add that as a separate solution.

Otávio Décio
A: 

You should organise in a sensible way. Having one solution folder per project is meaningless.

Something we use a lot is this

-> Web (all web projects) -> Data (any data related projects) -> Test (All unit testing projects)

Ray Booysen
+2  A: 

In my experience they just make things more confusing, for the reason MSDN states. If you right-click on a real folder in VS, you get the "Open Folder in Windows Explorer" command. If you right-click on a solution folder, nothing. Plus they tend to mess up routines that collapse the solution explorer; things inside solution folders don't collapse properly.

If you have so many projects in a solution that you feel like you need solution folders to sort them out, consider whether you could, instead, create separate solutions.

Kyralessa
+7  A: 

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.

ChrisA
This is a great, informative answer...but it doesn't have much to do with the question asked.
Kyralessa
It was aimed at "do you find 'Solution Folders' useful?" I think my answer was relevant to that. Our use of solutions has no drawbacks, so no comment there. By noting that solns are effectively groups of projects, it should also be clear that putting each proj in its own one is not a good idea.
ChrisA
... also, re-reading the OP's question, he might not have meant each project in a separate soln, just in a solution. This would be sensible, if the projects belonged together in some way.
ChrisA
+4  A: 

We use Solution Folders quite a bit to "associate" projects within a Solution. For example, most of our "projects" have 3 actual projects - implementation, unit tests and integration tests. We put all 3 in one Solution Folder. We also might put all Infrastructure in one and all CAB Modules in another. Basically when you have a Solution with 50+ projects, it helps to keep them organized so you can expand only what you're looking for and find things based on logical grouping.

ctacke
+10  A: 

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!

rstevens
I've been using solution folders for ages and never noticed that I could build by right clicking on the folder! +1
Benjol
A: 

For situations in which a WPF application is being developed that has designers accessing the solution in Expression Blend, the solution folders are ignored in the Blend environment. Therefore, all projects will be displayed at the top level still.

Also, when Blend loads the solution, a message box is displayed stating "Solution Folders are not supported. Nested projects will be loaded normally." The "Don't show this message again" option can be checked but it is still somewhat of a nuisance.

YeahStu
A: 

Here is a related question I asked a while back. One of my answers there talks about some of the pros/cons of solution folders, and how I am currently using them.

Benjol