c++visual-studio-2013projectdirectory-structureout-of-source

How to create an out of source tree project with Visual Studio?


I use the Show All Files feature in the solution explorer that displays project files in a folder structure that mirrors the file system, instead of using Visual Studio's filters. My goal is to create a Visual Studio project outside of the source tree that still lists the files in their directory structure.

What I did so far is to create an empty solution and project in the directory structure shown below. Then I selected the three folders inside the src directory and dragged them into the project. They got added to the project but they show up as a plain list in the solution explorer, not in their native directory structure.

repository
├─ src
│  ├─ types
│  │  ├─ *.h
│  │  └─ *.cpp
│  ├─ managers
│  │  ├─ *.h
│  │  └─ *.cpp
│  └─ modules
│     ├─ *.h
│     └─ *.cpp
└─ project
   ├─ *.sln
   └─ *.vcxproj

How can I create a project that is located out of the source tree without breaking the mentioned file system view?


Solution

  • I couldn't find out how to do out of source tree projects in Visual Studio so I think it is not supported. To solve the problem, we added all file names that Visual Studio uses to our .gitignore. Those lists are provided on the internet, for example by Github.