[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.] The Project Subtype sample demonstrates the capabilities of Visual Studio's support for project subtypes, which allow a VSPackage to "inherit" an existing Visual Studio project type and add to, change, or remove parts of its functionality. For details about project subtypes, see Project Subtypes.
The Project Subtype sample demonstrates the following features:
-
Add a template to the New Project dialog box.
-
Load and save subtype-specific data in the project file.
-
Handle specialized deployment by generating an MSBuild targets file and executing it.
-
Add a command to the project context menu.
-
Add a subtype-specific deployment property page.
-
Remove a property page that would otherwise be shown.
-
Override a file's normal icon in Solution Explorer.
Security Note |
|---|
| This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended. |
Building and running the Project Subtype sample
As is typical, you should build the Project Subtype sample in the normal Visual Studio registry hive and then run it using the experimental hive.
To build the Project Subtype sample
-
Start Visual Studio. Open the ProjectSubtype.sln file.
The default location is <drive>:\Program Files\Visual Studio 2005 SDK\<build number>\VisualStudioIntegration\Unsupported\CS_Samples\ProjectSubtype\ProjectSubtype
-
On the Build menu, choose Rebuild Solution.
-
Run the following command at the Visual Studio command line to merge command bars and other UI items:
devenv.exe /setup /rootsuffix exp
Note |
|---|
| The sample registers itself by invoking the RegPkg tool in a post-build event, defined in the Properties window of the project. |
To run the Project Subtype sample
-
Start Visual Studio using the experimental build by typing the following at the Visual Studio command line:
devenv.exe /rootsuffix exp
-
To see the new template, on the File menu, choose New, then choose New Project. In the Project types box, select Task Project. Click OK to accept the default names and create the project.
Note that in Solution Explorer, the MyTask.cs file has an icon different than the C# file right above it.
-
Double-click Properties in Solution Explorer to open the Properties window. Open the Deployment tab to see the custom property page.
-
On the Build menu, choose Deploy Solution. Visual Studio builds the solution and, as its custom deployment step, generates a targets file:
------ Deploy started: Project: Project1, Configuration: Debug Any CPU ------
Deploying
Generating file: ...\bin\Debug\MyTargets.targets
Updating debug launch parameters
-
Right-click the project in Solution Explorer and choose the custom menu command Open Target File.
The following table lists the VSIP interfaces implemented by the Project Subtype sample.
The following table lists the important files used in the implementation of the Project Subtype sample.
|
Source File
|
Description
|
| VsPkg.cs | Standard implementation of ProjectSubtype, derived from the Package class. Attributes provide registration information for the specialized property page, VSPackage, and project factory. |
| Project.cs | SpecializedProject inherits from FlavoredProject and implements IVsProjectFlavorCfgProvider. |
| DeployPropertyPage.cs | DeployPropertyPage inherits from Form and implements IPropertyPage. |
| SpecializedCfg.cs | SpecializedCfg implements IVsProjectFlavorCfg, IVsDeployableProjectCfg, and IPersistXMLFragment. |
See Also