YeahStu
YeahStu

Reputation: 4052

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?

Upvotes: 12

Views: 13962

Answers (10)

goku_da_master
goku_da_master

Reputation: 4317

A disadvantage to using solution folders is how they look in your version control system. Since solution folders are logical folders you won't see them in the VCS. Instead you will see all your projects in one flat list.

This has caused confusion for me since the structure can look quit different especially if you have files in your solution folders instead of just projects.

Upvotes: 0

Benjol
Benjol

Reputation: 66607

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.

Upvotes: 0

YeahStu
YeahStu

Reputation: 4052

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.

Upvotes: 0

mmmmmmmm
mmmmmmmm

Reputation: 15533

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!

Upvotes: 16

ctacke
ctacke

Reputation: 67198

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.

Upvotes: 6

ChrisA
ChrisA

Reputation: 4193

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.

Upvotes: 12

Ryan Lundy
Ryan Lundy

Reputation: 210350

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.

Upvotes: 3

Ray Booysen
Ray Booysen

Reputation: 30031

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)

Upvotes: 2

Otávio Décio
Otávio Décio

Reputation: 74290

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.

Upvotes: 3

GWLlosa
GWLlosa

Reputation: 24433

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.

Upvotes: 1

Related Questions