Monday, March 18, 2013

SharePoint 2010 - Features Overview

Overview
Feature is a server side functional component which can be installed and activated at various scopes throughout a SharePoint instance. Additionally, a feature can be used to replace a standard control or functionality with your own custom functionality.
For example, the search box which appears in the upper-right corner of every standard SharePoint layout can be replaced with a custom search control.

Scope of a feature
Every feature has an activation scope that can assume one of the following values:
1) Farm - The feature will target the entire SharePoint farm.
2) WebApplication - The feature targets a single web application and all the contained Site Collections.
3) Site - The feature will target a single Site Collection and all of its websites.
4) Web - The feature targets a single website.

Components of feature
1) Feature Manifest (Feature.xml) - Each time you develop a feature, SharePoint at minimum creates an XML file, named Feature.xml and called the feature manifest, and stores it on every front-end web server of the farm in a sub-folder of the SharePoint 14_Root\TEMPLATE\FEATURES directory.
2) Feature Elements (Elements.xml) - These elements correspond to zero or more ElementManifest tags, which are still defined through XML files, and zero or more ElementFile tags, which declare files supporting the feature.

The feature manifest file structure
Following is the structure of a Feature manifest file.
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
ActivateOnDefault = "TRUE" | "FALSE"
AlwaysForceInstall = "TRUE" | "FALSE"
AutoActivateInCentralAdmin = "TRUE" | "FALSE"
Creator = "Text"
DefaultResourceFile = "Text"
Description = "Text"
Hidden = "TRUE" | "FALSE"
Id = "Text"
ImageUrl = "Text"
ImageUrlAltText = "Text"
ReceiverAssembly = "Text"
ReceiverClass = "Text"
RequireResources = "TRUE" | "FALSE"
Scope = "Text"
SolutionId = "Text"
Title = "Text"
UIVersion = "Text"
Version = "Text" >
</Feature>

Properties of Feature Manifest
1) ActivateOnDefault - An optional Boolean attribute with a default value of True. It applies only to Farm-scoped or WebApplication-scoped features anddetermines whether the feature will be activated by default during installation. For WebApplication-scoped features, if this attribute is set to True, the feature will also be activated when a new web application is created.
2) AlwaysForceInstall - This is an optional Boolean attribute with a default value of False. When set to True, it forces the feature to be installed—even if it is already installed.
3) AutoActivateInCentralAdmin - This is an optional Boolean attribute with a default value of False. It defines whether the feature will be activated by default in the Administrative website hosting the SharePoint Central Administration. It does not apply to Farm-scoped features.
4) Creator - This is an optional description of the feature’s creator.
5) DefaultResourceFile - This is optional text that defines the name of a common resource file, usually shared with other features released by the same creator. By default, SharePoint will look for resources in a file in the path SharePoint14_Root\TEMPLATE\FEATURES\FeatureName\Resources, with a file name such as Resources.Culture.resx (the Culture value can be any of the standard culture names defined by the Internet Engineering Task Force (IETF), such as en-US, it-IT, fr-FR, and so on.
6) Description - This is optional text that describes the feature in the features’ management UI. You can define it using a resource string in the form $Resources:ResourceName. For example, if the feature description is a resource item with a key value of “FeatureDescription,” the corresponding value should be $Resources: FeatureDescription.
7) Hidden - This is an optional Boolean attribute with a default value of False. When set to True, the feature will be hidden from the UI and can be activated or deactivated only through the command line tools or by using the Object Model.
8) Id - This is a required attribute of type text, which must contain an ID (GUID) that uniquely identifies the feature.
9) ImageUrl - This is optional text that defines the site-relative URL of an image used to render the feature in the UI.
10) ImageUrlAltText - This is optional text that defines alternate text for the image representing the feature in the UI (see ImageUrl). You can define this using a resource string, just like the Description property.
11) ReceiverAssembly - This is optional text that defines the strong name of an assembly that SharePoint will search for in the Global Assembly Cache (GAC) and that provides a receiver class to handle the feature’s events.
12) ReceiverClass - This is optional text that defines the full class name of a receiver class to handle the feature’s events. SharePoint will search for the receiver class name in the ReceiverAssembly.
13) RequireResources - This is an optional Boolean attribute with a default value of False. It determines whether SharePoint requires that resources exist for the language of the current website or Site Collection to make the feature visible in the UI. This attribute does not affect the capability to activate and manage the feature from the command line or from the object model.
14) Scope - This is a required text attribute. It defines the scope within which the feature can be activated. The possible values are: Farm, WebApplication, Site, and Web. SolutionId This is optional text that defines the ID of the solution to which the features belongs.
15) Title - This is optional text that defines the title of the feature and that is visible in the features’ management UI. It is limited to a maximum length of 255 characters. You can define it using a resource string, as described in the Description property.
16) UIVersion - This is optional text that declares the UI version supported by the feature. The accepted values are 3 (for Windows SharePoint Services 3.0) and 4 (for Microsoft SharePoint Foundation 2010).
17) Version - This is optional text that defines the version of the feature. It can be made of up to four numbers, delimited by periods. For example, it might be 1.0.0.0, 1.0.0.1, and so on.

The feature elements file structure
<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Title="My Sample Web Part" Description="Deploys a custom Web Part." Id="c46c270e-e722-4aa0-82ba-b66c8dd61f4e" Scope="Site" Version="1.0.0.0">
<ElementManifests>
<ElementManifest Location="SampleWebPart\Elements.xml" />
<ElementFile Location="SampleWebPart\SampleWebPart.webpart" />
</ElementManifests>
</Feature>

Feature Element Types
Following are the available features elements in SharePoint 2010:
1) ContentTypeBinding - Used to provision a content type on a list defined in a site template. Can be scoped to Site.
2) ContentType - Defines a content type, ready to be used in lists or libraries. Can be scoped to Site.
3) Control - Used to customize the configuration of an existing delegate control, or to declare a new delegate control to override SharePoint’s standard controls. Can be scoped to Farm, WebApplication, Site, and Web.
4) CustomAction - Defines an extension to the standard user interface. For example, you can use CustomAction to define a new button on a ribbon bar, a new menu item on a standard menu, or a new link on a site settings page. Can be scoped to Farm, WebApplication, Site, and Web.
5) CustomActionGroup - Groups custom actions. Can be scoped to Farm, WebApplication, Site, and Web.
6) DocumentConverter - Declares a document converter that can convert a document from a type X to a type Y. Requires some custom development, to implement the converter. Can be scoped to WebApplication.
7) FeatureSiteTemplateAssociation - Allows associating a feature to a specific site template definition for the purpose of provisioning the feature together with the site definition, when you create a new site with that definition. Can be scoped to Farm, WebApplication, and Site.
8) Field - Declares a Site Column definition. Can be scoped to Site.
9) HideCustomAction - Hides an existing custom action defined by another custom action or implemented by default in SharePoint. Can be scoped to Farm, WebApplication, Site, and Web.
10) ListInstance - Provisions an instance of a list definition, together with a specific configuration. Can be scoped to Site and Web.
11) ListTemplate - Defines a list template for the purpose of provisioning a custom lists’ definitions. Can be scoped to Web.
12) Module - Allows provisioning custom pages or files to a site. Module can also be used to deploy configured Web Parts, ListView Web Parts over existing or provisioned lists, NavBar links, custom Master Pages, and to configure properties of the target feature. Can be scoped to Site and Web.
13) PropertyBag - Assigns properties and metadata to items (File, Folder, ListItem, Web) through features. Can be scoped to Web.
14) Receivers - Defines a custom event receiver. Can be scoped to Web.
15) WebTemplate - Allows deploying a website template, even through a sandboxed solution so that it can create site instances based on that template. Can be scoped to Site.
16) Workflow - Deploys a workflow definition on a target site. Can be scoped to Site.
17) WorkflowActions - Defines custom workflow actions for SharePoint Designer 2010. Can be scoped to Farm.
18) WorkflowAssociation - Associates a workflow with its target. Can be scoped to Site, Web.

Features and Solutions Deployment
To deploy a feature, you need to copy the feature’s folder to the SharePoint14_Root\TEMPLATE\FEATURES path of every target server for the feature. When this is complete, you can use the STSADM.EXE command line tool to install and later activate the feature.

Hope this article gave you an overview of the components of a feature. In the upcoming posts we will figure out the steps involved in the development and deployment of a SharePoint 2010 feature.

References
1) Microsoft SharePoint 2010 Developer Reference, by Paolo Pialorsi - Book

1 comment:

  1. Thank you for this excellent overview. The above detail helped me to learn and explore so much about this great application. I will keep visiting your blog to learn more. Keep sharing.
    electronic signature for sharepoint

    ReplyDelete

Note: Only a member of this blog may post a comment.