在Visual Studio中丢失了项目目录结构? [英] Project Directory Structure Lost in Visual Studio?

查看:594
本文介绍了在Visual Studio中丢失了项目目录结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Visual Studio 2015社区。我是一个经验丰富的程序员,但对VS还是陌生的,文件表示形式使我感到困惑。我已经创建了一个解决方案,并添加了一个现有项目。 VS向我显示了所有项目文件(在我的情况下是C ++项目,因此 .c .cpp .h 文件)放在解决方案资源管理器中的一棵树上。



相反,如果我打开类似这样的项目Sublime Text,VS Code,notepad ++或类似的东西,我看到正确的目录结构,因为它位于磁盘驱动器上;就像在终端中的文件浏览器/查找器或 ls / dir 中看到的那样。



我在发布之前已经完成了作业,并且在以下线程中,@ Andrey声明:


恐怕在MSVS中没有像目录
结构这样的概念。而且,MSVS并不是真正需要它,因为它使用的是平面
项目,并且层次结构是基于项目级别的,而不是基于
文件/目录的级别。



因为没有这种东西-您既不能自动
也不能手动使它。 MSVS的解决方案文件夹与
完全不同,因此将实际文件夹表示为解决方案
文件夹没有多大意义。




解决方案

我在下面的主题中找到了@Paul Easter给出的答案在理解这个怪异方面非常有帮助,这实际上是一个功能。项目结构的另一个概念正在起作用:


但是由于您不希望解决方案文件夹表现得像
那样,所以物理文件夹是因为您的解决方案布局可能不一定
使用与源代码管理布局相同的约定。解决方案
文件夹允许您自定义项目的层次结构,以便
可以将项目和项目随意组合在一起,然后
决定不喜欢并再次更改不必经历
的噩梦,即移动源代码控制项,而
会激怒团队的其余成员。


将Visual Studio解决方案文件夹作为真实文件夹



这是个好主意吗?我可以看到有人想要的位置,因为它允许他们按自己的意愿排列项目文件。在这一点上,我不喜欢它。我肯定部分是因为它对我来说是新事物,也有两个原因:

1.在一个有组织的项目中,目录层次结构不是任意的;

2.它在VS文件表示和操作系统结构之间增加了一层抽象。我喜欢直接访问正在处理的文件;在VS系统中,我感到与VS中的基础文件断开了奇怪而异常的连接。我必须承认这种层存在异常,这会给我带来麻烦。


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:

解决方案

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.

这篇关于在Visual Studio中丢失了项目目录结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆