Adding Existing folder(s) to a C++ Project in Visual Studio without creating a copy

775 Views Asked by At

I have a Visual Studio Solution containing multiple projects. (One Main Project and rest are used for testing the Main project)

Here, i have a shared folder within the solution which is used by all the projects within the solution. I need to include the entire shared folder in my Main project instead of adding existed items.

I am using Visual Studio Professional 2015 and i could not find "Add Existing folder" option in Visual Studio. Adding Existing items to a project will eliminate the folder structure in solution explorer which makes the usage more complex when included file count is huge.

I need to maintain a folder structure within the project. Moving the shared folder within the project directory and using "Show All Files" option will avoid the issue(tried based on the answers in some links) but it is not accurate in my case as the folder is being used by different projects.

Do i have any way to add existing folder (Outside the Project within the solution) to a project and maintain a folder structure so that the solution explorer looks more readable?

1

There are 1 best solutions below

0
On

I just found the solution to this issue. We are suppose to create a Filter (Virtual Solution Folder) within the Project. Option for creating Filter is available on following below steps,

  1. Select Visual Studio Project.

  2. In Solution Explorer, Disable "Show All Files" option. Note: When "Show All Files" option is enabled, your project will have an option to create a Folder instead of Filter.

  3. Create a Filter/Virtual Solution folder. (Name could be same as the existing folder name outside the VS project in order to maintain readability)

  4. Now, add required existing files to the Virtual Folder Solution from any location. (Inside/Outside project location)

By following the above steps, one can add set of existing files to a virtual folder structure in Visual Studio Solution. This is equivalent to adding an Existing folder to a Project Solution without copying it.