Mathivanan KP
Mathivanan KP

Reputation: 2044

Modifying project properties of custom project system in VisualStudio

I have tried to create a custom project system by walk through https://msdn.microsoft.com/en-us/library/vstudio/cc512961.aspx and succeeded. And now I want to modify the project properties of this created project system. The second part of this walk through is guiding to create property pages for solution properties. (Solution Explorer-> Right Click on Solution and select Properties) I don't want to modify solution properties, I need to customize project properties (Solution Explorer-> Right Click on Project and select Properties) by adding new tabs and other items for my custom project system. Please help me as soon as possible...

Upvotes: 0

Views: 734

Answers (1)

Matze
Matze

Reputation: 5508

If your project system is based on MPF custom tab pages can be integrated via the ProjectNode class. This class defines the GetConfigurationIndependentPropertyPages and GetConfigurationDependentPropertyPages methods; those are virtual methods and can be implemented by any derived type to return the type-id´s of IPropertyPage implementations.

internal class CustomProjectNode : ProjectNode
{
    protected override Guid[] GetConfigurationIndependentPropertyPages()
    {
        return new[] 
        {
            typeof(MyCustomPropertyPage).Guid
        };
    }
}

The IPropertyPage interface is the connector between the project system and the UI allowing to change properties, whereby the UI is an ordenary window (usually a Windows Forms Control). The property page implementation must be marked with the ComVisible- and ClassInterface-attributes, and optionally with a Guid-attribute, if one wants to keep control over the type-guid.

[ComVisible(true)]
[Guid("...")]
[ClassInterface(ClassInterfaceType.AutoDual)]
internal class MyCustomPropertyPage : IPropertyPage
{
    ...
}

In addition the property page type must be exposed through the ProvideObject-attribute on the package class.

[ProvideObject(typeof(MyCustomPropertyPage))]
class MyPackage : Package
{
}

Finally, to make the property page appear as a tab the SupportsProjectDesigner property of the custom project node must be set to true.

internal class CustomProjectNode : ProjectNode
{
    public CustomProjectNode() 
    {
        this.SupportsProjectDesigner = true;
    }
}

Upvotes: 1

Related Questions