Visual Studio Project vs. Solution

前端 未结 10 2163
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 18:48

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

相关标签:
10条回答
  • 2020-12-12 19:19

    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.

    0 讨论(0)
  • 2020-12-12 19:23

    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.

    0 讨论(0)
  • 2020-12-12 19:25

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

    0 讨论(0)
  • 2020-12-12 19:27

    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.

    0 讨论(0)
提交回复
热议问题