Elements of a Project Model

The interfaces and implementations of all projects in Visual Studio share a basic structure: the project model for your project type. In your project model, which is the VSPackage you are developing, you create objects that comply with your design decisions and work together with global functionality provided by the IDE. Although you control how a project item is persisted, for example, you do not control notification that a file must be persisted. When a user places the focus on an open project item and chooses Save on the File menu on the Visual Studio menu bar, your project type code must intercept the command from the IDE, persist the file, and send notification back to the IDE that the file is no longer changed.

Your VSPackage interacts with the IDE through services that provide access to the IDE interfaces. For example, through particular services, you monitor and route commands and provide context information for selections made in the project. All the global IDE functionality needed for your VSPackage is provided by services. For more information about services, see How to: Consume a Service.

Other implementation considerations:

  • A single project model can contain more than one project type.

  • Project types and the attendant project factories are registered independently with GUIDs.

  • Each project must have a template file or wizard to initialize the new project file when a user creates a new project through the Visual Studio UI. For example, the Visual C++ templates initialize what eventually become .vcproj files.

The Basic Project sample and the Figures Project sample included in this SDK provide examples of project implementation. The Basic Project sample demonstrates a simple type of project that does not contain registered file name extensions. Additionally, it shows an implementation of the IVsHierarchy interface and other related interfaces. The Figures Project sample demonstrates a custom project that has a hierarchy of items that can be built and uses the task list for output. It also shows how to localize all menus and strings in a satellite .dll file, and contributes statically and dynamically enabled commands to the menus.

The following illustration shows the primary interfaces, services, and objects that compose a typical project implementation. The Basic Project and the Figures Project samples both contain these interfaces and objects. Both of these samples also use the application helper, HierUtil7, to create the underlying objects and other programming boilerplate. For more information about the HierUtil7 application helper, see HierUtil7 and Using HierUtil7 Project Classes to Implement a Project Type (C++).

Project model
Visual Studio Project Model graphic

For more information about the interfaces and services listed in the previous diagram, and other optional interfaces not included in the diagram, see Project Model Core Components.

Projects can support commands and therefore must implement the IOleCommandTarget interface to participate in command routing through the command context GUIDs.

See Also

Concepts

Checklist: Creating New Project Types

HierUtil7

Using HierUtil7 Project Classes to Implement a Project Type (C++)

Project Model Core Components

Creating Project Instances with Project Factories

Visual Studio Integration Samples

How to: Consume a Service

Creating Project Types