Bagikan melalui


Solutions Overview

A solution is a grouping of one or more projects that work together to create an application. The project and status information pertaining to the solution are stored in two different solution files. The solution (.sln) file is text-based and can be placed under source code control and shared between users. The solution user option (.suo) file is binary. As a result, the .suo file cannot be placed under source code control and contains user-specific information. These files are analogous to the group (.vbg) files used in Visual Basic or the workspace (.dsw) and user options (.opt) files used in previous versions of Visual C++.

Any VSPackage can write to either type of solution file. Because of the nature of the files, there are two different interfaces implemented to write to them. The IVsPersistSolutionProps interface writes text information to the .sln file and the IVsPersistSolutionOpts interface writes binary streams to the .suo file.

The VSPackage registers itself as participating in solution persistence by putting a top-level key in the registry called SolutionPersistence. Under that is a series of keys labeled with a user-friendly name (in the case of the Solution Extender sample, SolutionNotes).

The folder default value contains the GUID (REG_SZ) for the VSPackage as shown in the following table.

[HKLM\<Application ID Registry Root>\SolutionPersistance\<Your Type Name>]

Name

Type

Data

Description

@

REG_SZ

GUID

The GUID of your VSPackage.

Note

A project does not have to explicitly write an entry for itself into the solution file; the environment handles that for the project. Therefore, unless you want to add additional content specifically to the solution file, you do not need to register your VSPackage in this way.

Each VSPackage supporting solution persistence uses three interfaces, the IVsSolutionPersistence interface, which is implemented by the environment and called by the VSPackage, and IVsPersistSolutionProps and IVsPersistSolutionOpts, which are both implemented by the VSPackage. The IVsPersistSolutionOpts interface only needs to be implemented if private information is to be written by the VSPackage to the .suo file.

When a solution is opened, the following process takes place.

  1. The environment reads the solution.

  2. If the environment finds a CLSID, it loads the corresponding VSPackage.

  3. If a VSPackage is loaded, the environment calls QueryInterface for IVsPackage interface, for the interface that the VSPackage requires.

    1. When reading from an .sln file, the environment calls QueryInterface for IVsPersistSolutionProps.

    2. When reading from an .suo file, the environment calls QueryInterface for IVsPersistSolutionOpts.

Specific information relating to the use of these files can be found in Solution (.sln) File and Solution User Options (.Suo) File.

Note

If you want to create a new solution configuration consisting of two projects' configurations and excluding a third from the build, you need to use the Property Pages UI or automation. There are no available VSIP API-level interfaces that allow the direct manipulation of the solution build manager configurations and their properties. You can manipulate the solution build manager using the SolutionBuild class from DTE in the automation model. For more information, see Automation Model. For more information relating to configuring solutions, see Solution Configuration.

See Also

Reference

IVsPackage

IVsPersistSolutionOpts

IVsPersistSolutionProps

IVsSolutionPersistence