What is a solution folder in visual studio

2019-01-13 20:07发布

I have a vs 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.

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....

I want that myFolder added to the solution, so that items are also under source control...

6条回答
ゆ 、 Hurt°
2楼-- · 2019-01-13 20:16

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.

However Visual Studio does not maintain a mapping between the solution folder and the physical folder which means that:

  • 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".

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"

查看更多
Explosion°爆炸
3楼-- · 2019-01-13 20:17

From 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."

what you want is not what the composer meant in Solution Folder, he 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...

have a great day.

查看更多
可以哭但决不认输i
4楼-- · 2019-01-13 20:20

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 contains file references and project references)

查看更多
我命由我不由天
5楼-- · 2019-01-13 20:29

What I have done historically is to create a project for just holding files (DLLs, etc.)

You can do that as well. This project can be named as whatever folder you are trying to create.

查看更多
手持菜刀,她持情操
6楼-- · 2019-01-13 20:32

Follow this...

  1. Create the solution folder from VS.
  2. Right click solution folder to create new project.
  3. 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
  4. Click the ok to create the project

Then the new project will be put inside your new New Physical Folder.

查看更多
乱世女痞
7楼-- · 2019-01-13 20:36

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".

查看更多
登录 后发表回答