Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project Directory Structure Lost in Visual Studio?

I'm learning Visual Studio 2015 Community. I'm a seasoned programmer, but new to VS, and the file representation is confusing me. I've created a solution, and added an existing project. VS is showing me all project files (In my case a C++ project, so .c, .cpp, and .h files) on one tree level in Solution Explorer.

In contrast, if I open said project in something like Sublime Text, VS Code, notepad++, or the like, I see the proper directory structure as it sits on the disk drive; as one would see it in File Explorer/Finder or ls/dir in a terminal.

I have done my homework before I posted, and in the following thread, @Andrey states:

I am afraid there is no such concept in MSVS like "directory structure". Moreover, MSVS doesn't really need it because it uses flat projects and hierarchies are based on project level, not on the file/directory level.

As there is no such thing - you can't have it neither automatically nor manually. MSVS has solution folders which is quite different thing and there isn't much sense in expressing real folders as solution folders.

Visual Studio as Code Browser : How to preserve the directory structure?

Is this true? There is much meaning in the arrangement of files, and the flat representation in VS makes a project harder to understand; file location in the directory structure are important. Is there a way to view the proper directory structure in VS?

In my situation, I'm working with Quickfix, which supports multiple versions (4.0, 4.1, 4.2, etc.). Each of these have different classes and files with the same name.

As you can see from the screen shots below, they are all neatly arranged in different folders on disk, but VS's representation of these files is immensely confusing:

enter image description here

enter image description here

like image 279
kmiklas Avatar asked Mar 23 '17 19:03

kmiklas


People also ask

How do I show the project folder in Visual Studio?

Open your project in Visual Studio > click the Show All Files button > expand the bin , Debug > select and right-click the parent folder > choose Include in Project option.

Where is the directory in Visual Studio?

In Visual Studio, click File > Open > Folder. Navigate to the folder, and click Select Folder. This opens the folder in Solution Explorer and displays its contents, files and any subfolders.

How do I create a project folder structure?

Navigate to the project's Documents tool. Create subfolders under the main root folder that are best aligned with how you want the documents in your project organized. Note: See Create a Folder for more information on building folders.


1 Answers

I found the answer given by @Paul Easter in the thread below to very helpful in understanding this "quirk," which is really a "feature." A different concept of project structure is at work:

But as for the reason you do not want solution folders to behave like "physical" folders is because your solution layout may not necessarily use the same convention as your source control layout. Solution folders allow you to customize the hierarchy of your projects so that you can group projects and items together any way you like, and then decide you don't like it and change it again without having to go through the nightmare of moving source control items around and irritating the rest of your team.

Visual Studio Solutions Folder as real Folders

Is this a good idea? I can see where some people would like it, as it allows them to arrange project files as they wish. At this point, I dislike it; I'm sure in part because it is new to me, but also for these two reasons:
1. In an organized project, the directory hierarchy is not arbitrary; the Principal Engineer arranges files in a certain way for good reasons.
2. It adds a layer of abstraction between the VS file representation and the operating system structure. I like direct access to the files that I'm working on; with the VS system, I feel oddly and eerily disconnected from the underlying files in VS. I must admit a fear that this layer has its anomalies, and will cause problems for me.

like image 138
kmiklas Avatar answered Oct 13 '22 10:10

kmiklas