Visual Studio 项目与解决方案

发布于 2024-08-23 14:36:36 字数 31 浏览 5 评论 0原文

作为VS新手,我怎么看待这两个概念,有什么区别?

Being new to VS, how may I think of these two concepts, what is the difference?

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

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

发布评论

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

评论(10

流年里的时光 2024-08-30 14:36:36

我在其他答案中发现了一些缺失的信息(至少对于来自其他 IDE(例如 Eclipse)的人来说)。说解决方案是项目的容器只是事情的一部分。 VS 项目的概念特征(决定其“粒度”的因素)是一个项目产生一个输出:通常是可执行文件或库 (dll)。因此,如果您要编写三个使用相关代码的可执行文件,您将创建一个解决方案和至少三个项目 - 可能更多。

I find some missing information in the other answers (at least for people who come from other IDEs like, say, Eclipse) . To say that a solution is a container for projects is only part of the thing. The conceptual feature of a VS project (what determines its 'granularity') is that one project produces one output: typically an executable or a library (dll). So, if you are going to code three executables that uses related code, you'll create one solution and at least three projects - probably more.

北音执念 2024-08-30 14:36:36

解决方案是项目的容器,并跟踪项目之间的依赖关系。

A solution is a container for projects, and tracks dependencies between projects.

美人骨 2024-08-30 14:36:36

只是想出一个比喻......

解决方案就像一座房子,一个项目就像一个房间。每个房间都提供一项功能,而房子作为房间的容器,提供将房间连接在一起并适当组织它们的方法。

有点老套,但我是临时编造的,所以请耐心等待:)

Just to come up with a metaphor..

A solution is like a house, a project like a room. Each room provides a piece of functionality whereas the house, a container of rooms, provides the means to link the rooms together and organize them appropriately.

Kind of corny but I made it up on the fly, so bear with me :)

微暖i 2024-08-30 14:36:36

Visual Studio 似乎让事情变得更加混乱,这无济于事。 “新建项目”实际上创建了一个包含项目的新解决方案。 “打开项目”实际上打开一个包含一个(或多个)项目的解决方案。 (文件菜单显示“打开项目/解决方案”,但它实际上是打开解决方案。没有“关闭项目”,只有“关闭解决方案”,这是准确的。

因此,在 VS 中,您始终在解决方案中工作。许多解决方案只包含一个项目和新的开发人员可能会将它们视为同一件事,但是您可以将其他项目添加到解决方案中。

It doesn't help that Visual Studio seems to make things more confusing. "New Project" actually creates a new SOLUTION containing a project. "Open Project" actually opens a solution containing one (or many) project. (The file menu says "Open Project/Solution" but it really is opening solutions. There is no "Close Project" only "Close Solution" which is accurate.

So, in VS you are always working within a solution. Many solutions contain only one project and newer developers are likely to think of them as the same thing. However you can add other projects into a solution.

夏九 2024-08-30 14:36:36

如果有人决定向下滚动到目前为止...我认为 MS 文档 在描述差异方面做得非常好。我已在这里复制粘贴(并改写)相关部分:

当您在 Visual Studio 中创建应用程序、应用程序、网站、Web 应用程序、脚本、插件等时,您将从一个项目开始。从逻辑意义上讲,项目包含所有源代码文件、图标、图像、数据文件以及将编译成可执行程序或网站的任何其他内容,或者执行编译所需的其他内容。项目还包含程序将与之通信的各种服务或组件可能需要的所有编译器设置和其他配置文件。

如果您不愿意,则不必使用解决方案或项目。您只需在 Visual Studio 中打开文件并开始编辑代码即可。

从字面意义上来说,项目是一个定义虚拟文件夹的 XML 文件(.vbproj.csproj.vcxproj)层次结构以及它“包含”的所有项目和所有构建设置的路径。

在 Visual Studio 中,解决方案资源管理器使用项目文件来显示项目内容和设置。编译项目时,MSBuild 引擎使用项目文件来创建可执行文件。您还可以自定义项目以产生其他类型的输出。

从逻辑意义上讲,项目包含在解决方案的文件系统中,该解决方案可能包含一个或多个项目,以及生成信息、Visual Studio 窗口设置以及与任何项目。从字面意义上讲,解决方案是一个具有自己独特格式的文本文件;它通常不适合手动编辑。

解决方案具有关联的 .suo 文件,用于存储参与该项目的每个用户的设置、首选项和配置信息。

In case anyone decides to scroll down this far... I thought the MS docs did a pretty good job at describing the differences. I've copy pasted (and rephrased) the relevant bits here:

When you create an app, application, website, Web App, script, plug-in, etc in Visual Studio, you start with a project. In a logical sense, a project contains of all the source code files, icons, images, data files and anything else that will be compiled into an executable program or web site, or else is needed in order to perform the compilation. A project also contains all the compiler settings and other configuration files that might be needed by various services or components that your program will communicate with.

You don't have to use solutions or projects if you don't want to. You can simply open the files in Visual Studio and start editing your code.

In a literal sense, a project is an XML file (.vbproj, .csproj, .vcxproj) that defines a virtual folder hierarchy along with paths to all the items it "contains" and all the build settings.

In Visual Studio, the project file is used by Solution Explorer to display the project contents and settings. When you compile your project, the MSBuild engine consumes the project file to create the executable. You can also customize projects to product other kinds of output.

A project is contained, in a logical sense and in the file system, within a solution, which may contain one or more projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren't associated with any project. In a literal sense, the solution is a text file with its own unique format; it is generally not intended to be edited by hand.

A solution has an associated .suo file that stores settings, preferences and configuration information for each user that has worked on the project.

女皇必胜 2024-08-30 14:36:36

一个解决方案可以有多个项目。

该解决方案还可以管理不同项目之间的依赖关系...确保每个项目都按照适当的顺序构建,以便最终解决方案发挥作用。

A Solution can have many Projects.

The Solution can also handle managing the dependencies between its different Projects...making sure that each Project gets Built in the appropriate order for the final Solution to work.

秋意浓 2024-08-30 14:36:36

项目包含组成应用程序或应用程序组件的可执行文件和库文件。

解决方案是组成应用程序的逻辑相关项目的占位符。例如,您可以为应用程序的 GUI、数据库访问层等创建单独的项目。这些项目将是程序功能的特定部门,而解决方案将是将所有这些项目统一到一个应用程序下的总括。

A project contains executable and library files that make up an application or component of an application.

A solution is a placeholder for logically related projects that make up an application. For example, you could have separate projects for your application's GUI, database access layer, and so on. The projects would be specific divisions for your program's functionality, and the solution would be the umbrella unifying all of them under one application.

梦幻的味道 2024-08-30 14:36:36

解决方案是一个可读的文本文件,其扩展名为.sln,并具有描述其包含的项目的结构化内容。 项目是一个可读的XML格式的文本文件,其扩展名为.vcxproj,并根据其XML模式具有结构化内容,其主要用途是包含源代码文件名及其依赖项或对其他项目源代码的引用的列表。

A solution is a readable text file whose extension is .sln and having a structured content that describes the projects that it contains. A project is a readable XML formatted text file whose extension is .vcxproj and having a structured content according to its XML schema, and whose primary purpose is to contain the listing of source codes filenames and their dependencies or references to other project's source codes as well.

燕归巢 2024-08-30 14:36:36

解决方案是项目的容器 - 您还可以使用它们来组织在不同相关项目(共享 dll 等)中使用的项目。

Solutions are containers for projects - you can also use them to organize items that are used across different related project (shared dll's and such).

许一世地老天荒 2024-08-30 14:36:36

解决方案是 Visual Studio 用于组织一个或多个相关项目的容器。当您在 Visual Studio 中打开解决方案时,它将自动加载其包含的所有项目。

当您在 Visual Studio 中创建新项目时,如果尚未打开解决方案,它会自动创建一个解决方案来容纳该项目。

您可以在解决方案中设置项目对其他项目的依赖关系。依赖的项目在其所依赖的项目构建完成后构建。

有关更多详细信息,请参阅 - https://learn.microsoft.com /en-us/visualstudio/ide/quickstart-projects-solutions

如果您有 Eclipse 背景,您可能会去构建项目路径并添加对其他项目的依赖项或添加外部 jar。在 VS 中,您可以在一个名为解决方案的容器中执行此操作,其中所有相关项目都分组在一起。

例如。假设您正在 xamrin 中构建 Android 和 iOS 应用程序,那么会有一些通用代码和资源可以放入单独的项目中,然后您的 Android 和 iOS 项目可以依赖于这个通用代码项目。您也可以有项目来测试这些项目等。

Solutions are containers used by Visual Studio to organize one or more related projects. When you open a solution in Visual Studio, it will automatically load all the projects it contains.

When you create a new project in Visual Studio, it automatically creates a solution to house the project if there's not a solution already open.

You can set dependencies of projects on other projects in the solution. The dependent project is build after the project it is depending on is built.

For more details refer - https://learn.microsoft.com/en-us/visualstudio/ide/quickstart-projects-solutions

If you are from an Eclipse background you would probably go to build path of a project and add a dependency on other project or add an external jar. In VS you can do that in a single container called solution where all related projects are grouped together.

Eg. Let's say you are build and android and iOS app in xamrin, there would be some common code and resources that could go in a separate project and then your android and iOS projects can depend on this common code project. Also you could have projects to test these projects etc.

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