visual-studio Visual Studio 中的解决方案文件夹是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/374081/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is a solution folder in Visual Studio?
提问by Michael L
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.
我有一个 Visual Studio 2008 解决方案,我想在解决方案中包含一个真正的文件夹,但不是在项目级别,而是在解决方案级别。
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...
基本上在文件系统上我有 c:\mySolution\myFolder ...
I want that myFolder is added to the solution, so that items are also under source control...
我希望将 myFolder 添加到解决方案中,以便项目也受源代码控制......
采纳答案by Joe
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.
我发现的最佳解决方案是添加一个与物理文件夹同名的解决方案文件夹(在您的示例中为 myFolder),然后将该物理文件夹中的文件添加到解决方案文件夹中。
However Visual Studio does not maintain a mapping between the solution folder and the physical folder which means that:
但是 Visual Studio 不维护解决方案文件夹和物理文件夹之间的映射,这意味着:
- 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". 
- 随后使用 Visual Studio 在解决方案文件夹中创建的新文件不会自动放置在物理子文件夹中(我认为默认情况下它们是在解决方案根文件夹中创建的) 
- 添加到物理文件夹的文件在解决方案文件夹中不会自动可见,即使使用“显示所有文件”也是如此。 
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"
为了添加新文件,我总是在 Visual Studio 外的物理文件夹中创建新文件,然后使用“添加/现有项目”将其添加到解决方案文件夹中
回答by Vaibhav
What I have done historically is to create a project for just holding files (DLLs, etc.)
我过去所做的是创建一个仅保存文件(DLL 等)的项目。
You can do that as well. This project can be named as whatever folder you are trying to create.
你也可以这样做。该项目可以命名为您尝试创建的任何文件夹。
回答by Allen Wang
Follow this...
按照这个...
- Create the solution folder from Visual Studio.
- Right click the solution folder to create a new project.
- 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
- Click the OK button to create the project
- 从 Visual Studio 创建解决方案文件夹。
- 右键单击解决方案文件夹以创建一个新项目。
- 更改默认位置路径以在其后面添加新的物理文件夹名称并使用反斜杠。类似于... C:\Project\Test\New Physical Folder
- 单击确定按钮创建项目
Then the new project will be put inside your new New Physical Folder.
然后新项目将被放入您的新项目中New Physical Folder。
回答by Tomer W
From MSDN:
来自 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...
对于您的问题,我认为这是您的安装项目收集这些文件的工作:安装说明、全局帮助等...
回答by Vilx-
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".
您还可以在解决方案文件夹中添加独立文件,它们将受到源代码控制。但要注意 VS 倾向于将这些文件与解决方案文件放在同一文件夹中 - “解决方案文件夹”是虚拟的,不对应于真实的文件系统文件夹。要拥有真正的文件系统文件夹,我认为您必须自己创建结构,然后选择“添加现有项目”。
回答by Bert Huijben
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.)
您可以使用解决方案文件夹对解决方案中的文件进行分组,但解决方案文件夹并不代表磁盘上的文件夹,正如其徽标所暗示的那样。(它可以包含文件引用和项目引用。)


