What is a solution folder in Visual Studio?

Visual StudioTfsDirectorySolution

Visual Studio Problem Overview


I have a Visual Studio 2008 solution, and I would like to include a real folder in the solution, but not at the project level, instead at the solution level.

I noticed you can right click the solution and add a solution folder, but it comes up as some white folder, and I have my doubts as to exactly what it is supposed to be...

Basically on the file system I have c:\mySolution\myFolder...

I want that myFolder is added to the solution, so that items are also under source control...

Visual Studio Solutions


Solution 1 - Visual Studio

I also would like to be able to add physical folders to a solution, but unfortunately you can't do so outside a project.

The best solution I have found is to add a solution folder with the same name as the physical folder (myFolder in your example), then add files from that physical folder to the solution folder.

However Visual Studio does not maintain a mapping between the solution folder and the physical folder which means that:

  • new files subsequently created in the solution folder using Visual Studio are not automatically placed in the physical subfolder (I think they are created in the solution root folder by default)

  • files added to the physical folder are not automatically visible in the solution folder, even with "Show All Files".

To add new files, I therefore always create the new file in the physical folder outside Visual Studio, then add it to the solution folder using "Add/Existing Item"

Solution 2 - Visual Studio

What I have done historically is to create a project for just holding files (DLLs, etc.)

You can do that as well. This project can be named as whatever folder you are trying to create.

Solution 3 - Visual Studio

Follow this...

  1. Create the solution folder from Visual Studio.
  2. Right click the solution folder to create a new project.
  3. Change the default location path to add the new physical folder name right after it with the back slash. Something like...C:\Project\Test\New Physical Folder
  4. Click the OK button to create the project

Then the new project will be put inside your new New Physical Folder.

Solution 4 - Visual Studio

You can also add standalone files in a solution folder, and they will be source-controlled. But be wary that VS tends to put these files in the same folder as the solution file - the "Solution Folders" are virtual and don't corresspond to real filesystem folders. To have a real filesystem folders I think you would have to create the structure yourself and then choose "Add Existing Item".

Solution 5 - Visual Studio

From MSDN:

> "If you are working with a solution that contains numerous projects, you can use Solution Folders to organize related projects into groups and then perform actions on those groups of projects."

You don't want what the composer meant in Solution Folder. It made them to organize large solutions into groups.

For your problem, I think this is the job for your Installation Project to collect these files: Installation instructions, Global help, etc...

Solution 6 - Visual Studio

You can use a solution folder to group files in a solution, but a solution folder doesn't represent an on-disk folder, like its logo suggests. (It can contain file references and project references.)

Solution 7 - Visual Studio

My prefered solution is to add a Shared project, which is like a folder but with a special icon.

Visual studio shared project

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMichael LView Question on Stackoverflow
Solution 1 - Visual StudioJoeView Answer on Stackoverflow
Solution 2 - Visual StudioVaibhavView Answer on Stackoverflow
Solution 3 - Visual StudioAllen WangView Answer on Stackoverflow
Solution 4 - Visual StudioVilx-View Answer on Stackoverflow
Solution 5 - Visual StudioTomer WView Answer on Stackoverflow
Solution 6 - Visual StudioBert HuijbenView Answer on Stackoverflow
Solution 7 - Visual StudioMariksel AzemajView Answer on Stackoverflow