Using Features in SharePoint Foundation
Published: May 2010
Features in Microsoft SharePoint Foundation reduce the complexity involved in making simple site customizations, and they are robust when upgrades are applied to a deployment. Features eliminate the need to copy large chunks of code to change simple functionality. Features thus reduce versioning and inconsistency issues that may arise among front-end web servers.
Features make it easier to activate or deactivate functionality in the course of a deployment, and administrators can easily transform the template or definition of a site by simply toggling a particular Feature on or off in the user interface. Features provide the following capabilities:
Scoping semantics for determining where custom code runs
Pluggable behavior for installing or uninstalling Features within a deployment
Pluggable behavior for activating or deactivating Features at a given scope
A scoped property bag for storing data required by a Feature within its scope
The basis of a unified framework for distributed deployment of SharePoint Foundation solutions
Ability to upgrade Feature versions
Features are stored on the front-end web server in the %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\FEATURES directory. The Feature subfolder includes a Feature.xml file that defines the base properties of the Feature and the elements bound to it, such as XML files containing element manifests and any other supporting files. A Feature folder can contain a Feature.xml file and any number of supporting element files.
SharePoint Foundation supports only low-order ASCII characters, and no spaces, for Feature folder and file names.
Features can be installed and activated using the SharePoint Management Shell, through the object model, or through the stsadm tool. You can also activate a Feature through the user interface. Installing a Feature makes its definition and elements known throughout a server farm, and activating the Feature makes the feature available at a particular scope.
The Feature element is used in a Feature.xml file to define a Feature and to specify the location of assemblies, files, dependencies, or properties that support the Feature. A Feature includes a Feature.xml file and any number of files describing individual elements.
Items that were previously contained within a large site definition file have been broken out as separate elements within Features. An element is an atomic unit within a Feature. A Feature.xml file typically points to one or more XML files whose top-level Elements tag contains definitions for elements that support the Feature. There are several types of elements, such as an event handler, that can be included in a Feature. For specific information about the file format and XML elements used in the Feature.xml file, see Feature.xml Files.
For information about how Features affect the file format of the ONET.XML file in a site definition, see Site Definition (Onet.xml) Files.