Today I thought I’d share one of my development tips. Developing applications on SharePoint is often best done by leveraging out-of-the-box functionality to the highest extent possible. When discovering out-of-the-box functionality it can be challenging to find what you are looking for, especially when searching for feature definition that you stumble upon inside site definition onet.xml files. Here is a snippet from the BLANKINTERNET onet.xml file:
<WebFeatures>
<Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">
<!—Publishing –>
<Properties xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Key="ChromeMasterUrl" Value="~SiteCollection/_catalogs/masterpage/nightandday.master"/>
<Property Key="WelcomePageUrl" Value="$Resources:osrvcore,List_Pages_UrlName;/default.aspx"/>
<Property Key="PagesListUrl" Value=""/>
<Property Key="AvailableWebTemplates" Value="*-BLANKINTERNET#2;*-ENTERWIKI#0"/>
<Property Key="AvailablePageLayouts" Value=""/>
<Property Key="AlternateCssUrl" Value="" />
<Property Key="SimplePublishing" Value="false" />
</Properties>
</Feature>
</WebFeatures>
This is a hidden feature which is activated as a part of the site provisioning process when you create a Publishing Portal (BLANKINTERNET#0) site. Although this feature is not so hard to find since we can see the name of it in the comment, but not every feature reference in onet.xml files are this well commented. Like this one for example:
<SiteFeatures>
<!-- "A44D2AA3-AFFC-4d58-8DB4-F4A3AF053188" –>
<Feature ID="A44D2AA3-AFFC-4d58-8DB4-F4A3AF053188" />
</SiteFeatures>
Sure, you could run the following Powershell CmdLet to find the name of the feature:
Get-SPFeature | Where { $_.Id -eq "A44D2AA3-AFFC-4d58-8DB4-F4A3AF053188" }
But personally I prefer using Windows Search to find the feature. When you are developing for SharePoint you are most likely working on Windows Server 2008 R2 where Windows Search is not enabled by default. To make this feature available you have activate the role service Windows Search Service, which requires the File Server role.
When Windows Search is enabled, and your 14 Hive has been indexed you can search the FEATURES folder to get a result like this:
From this view you can easily find the file named feature.xml, and right click it to open the file location and open the file. The feature.xml file will tell you most of the thing you need to know about how a feature work, and how you can use it for your own applications. This is also where .NET Reflector is your best friend. From the feature.xml file you will find the assembly and the class which contains the FeatureActivated method holding all the secrets. Here is an example from the Publishing feature above:
<Feature
Id="22A9EF51-737B-4ff2-9346-694633FE4416"
Title="Publishing"
ReceiverAssembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
ReceiverClass="Microsoft.SharePoint.Publishing.PublishingFeatureHandler">
</Feature>
By finding the FeatureActivated method in the above referenced class Microsoft.SharePoint.Publishing.PublishingFeatureHandler in the also referenced assembly Microsoft.SharePoint.Publishing you will find the could which tells you what the feature does and where each setting ends up as a result of using feature properties when activating it. Sometimes you can also discover other properties while looking at the FeatureActivated method.
I hope this tip is helpful. It sure has saved some time for me. Cheers.