Visual Studio 中的解决方案文件夹是什么?

发布于 2024-07-10 15:39:50 字数 237 浏览 7 评论 0原文

我有一个 Visual Studio 2008 解决方案,我想在解决方案中包含一个真实的文件夹,但不是在项目级别,而是在解决方案级别。

我注意到您可以右键单击解决方案并添加一个解决方案文件夹,但它显示为一些白色文件夹,我怀疑它到底应该是什么......

基本上在文件系统上我有 c:\ mySolution\myFolder...

我希望将 myFolder 添加到解决方案中,以便项目也受到源代码控制...

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.

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 is added to the solution, so that items are also under source control...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

梅窗月明清似水 2024-07-17 15:39:50

我还希望能够将物理文件夹添加到解决方案中,但不幸的是您无法在项目之外执行此操作。

我发现的最佳解决方案是添加一个与物理文件夹(示例中为 myFolder)同名的解决方案文件夹,然后将该物理文件夹中的文件添加到解决方案文件夹中。

但是,Visual Studio 不维护解决方案文件夹和物理文件夹之间的映射,这意味着:

  • 随后使用 Visual Studio 在解决方案文件夹中创建的新文件不会自动放置在物理子文件夹中(我认为它们是在默认情况下解决方案根文件夹)

  • 添加到即使使用“显示所有文件”,物理文件夹也不会自动在解决方案文件夹中可见。

    即使使用

因此,要添加新文件,我总是在 Visual Studio 外部的物理文件夹中创建新文件,然后使用“添加/现有项目”将其添加到解决方案文件夹中

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"

匿名。 2024-07-17 15:39:50

我过去所做的就是创建一个仅保存文件(DLL 等)的项目,

您也可以这样做。 该项目可以命名为您尝试创建的任何文件夹。

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.

好听的两个字的网名 2024-07-17 15:39:50

按照此操作...

  1. 从 Visual Studio 创建解决方案文件夹。
  2. 右键单击解决方案文件夹以创建一个新项目。
  3. 更改默认位置路径,以在其后面添加带有反斜杠的新物理文件夹名称。类似于...C:\Project\Test\New Physical Folder
  4. 单击“确定”按钮创建项目

然后新项目将被放入新的新物理文件夹中。

Follow this...

  1. Create the solution folder from Visual Studio.
  2. Right click the solution folder to create a 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 button to create the project

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

浅笑依然 2024-07-17 15:39:50

您还可以在解决方案文件夹中添加独立文件,它们将受到源代码控制。 但请注意,VS 倾向于将这些文件与解决方案文件放在同一文件夹中 - “解决方案文件夹”是虚拟的,与真实的文件系统文件夹不对应。 要拥有真正的文件系统文件夹,我认为您必须自己创建结构,然后选择“添加现有项目”。

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

似最初 2024-07-17 15:39:50

我首选的解决方案是添加一个共享项目,它就像一个文件夹,但带有特殊的图标。

Visual Studio共享项目

My prefered solution is to add a Shared project, which is like a folder but with a special icon.

Visual studio shared project

短叹 2024-07-17 15:39:50

来自 MSDN:

“如果您正在使用包含多个项目的解决方案,则可以使用解决方案文件夹将相关项目组织成组,然后对这些项目组执行操作。”

您不想要作曲家在解决方案文件夹中的意思。 这使得他们将大型解决方案组织成组。

对于您的问题,我认为这是您的安装项目收集这些文件的工作:安装说明、全局帮助等......

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

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

蓝眸 2024-07-17 15:39:50

您可以使用解决方案文件夹对解决方案中的文件进行分组,但解决方案文件夹并不代表磁盘上的文件夹,如其徽标所示。 (它可以包含文件引用和项目引用。)

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

陪你搞怪i 2024-07-17 15:39:50
  1. 创建您的解决方案

     dotnet new sln -n demoProjectName  
      

    例如您的解决方案文件夹路径 C:\Projects\demoProjectName>

  2. 在同一解决方案路径中创建项目

     dotnet new classlib -n 持久性 
      
  3. 从解决方案文件夹路径中执行此操作

    C:\Projects\demoProjectName>   dotnet sln C:\Projects\demoProjectName\ 添加 C:\Projects\demoProjectName\Persistence\Persistence.csproj 
      

请注意:所使用的持久性只是您的项目名称的占位符。 classlib 用于 classLibrary 项目,它可以是控制台项目等。

  1. Create your Solution

     dotnet new sln -n demoProjectName 
    

    e.g. Your solution folder path C:\Projects\demoProjectName>

  2. Create a Project within the same solution Path

     dotnet new classlib -n Persistence
    
  3. From your solution folder path, do this

    C:\Projects\demoProjectName> dotnet sln  C:\Projects\demoProjectName\  add  C:\Projects\demoProjectName\Persistence\Persistence.csproj
    

Please note: Persistence as used is just a placeholder for your project name. classlib for classLibrary projects and it could be a console project and so on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文