Understanding SharePoint Features
First… What Is a Feature?
A feature is a mechanism to deploy and activate customizations to a SharePoint environment. Features can be activated in the user interface empowering the administrator or end user with the ability to easily enable or disable a customization. Features are made of a manifest or feature.xml, one or many additional element XML files and additional resource files if applicable. Read more at MSDN. The most important benefit to features is that they can be deployed with Solution Packages (WSP), using solution packages will keep you in a supported, restorable state and encourages developers to focus on deployment and packaging during the initial phases of development which is extremely important.
What Can I Install With Features?
- List Templates
- List Instances
- Files
(Images, Web Parts, Master Pages, etc) - Site Columns
- Event Handlers
- Custom Actions
- Content Types
- Workflows
- Feature Site Template Associations
- Content Type Bindings
- Delegate Controls
- Document Converters
The Feature.xml File
You can drill into the entire schema of the feature.xml file by reading the Feature.xml Files article at MSDN. We’re going to cover the important parts and talk about how to utilize features effectively.
Scope
Scope allows you to decide where this feature will be available for activation. This is a very powerful concept. For example, you could activate a new list template per sub site (scoped to the Web) or activate it once for the entire site collection (scoped to the Site).
Farm
Displays under Central Administration > Operations

Farm level features are useful for installing things such as configuration screens that might apply for the entire farm or the initial installation of a custom application built on SharePoint.
WebApplication
Displays under Central Administration > Application Management

Web application level features are useful for installing timer jobs as timer job are always scoped to run at the Web Application level.
Site (Site Collection)
Displays under Site Action > Site Settings > Site Collection Settings (or Site Settings if currently on the root site)
Web (Sub Site)
Displays under Site Actions > Site Settings

Activation Dependencies
Here’s an example of the activation dependencies node.
A good example of of an activation dependency is when you might have one feature install Site Columns and a second feature install the Content Types. SharePoint uses activation dependencies for activating publishing functionality. If you attempt to activate publishing at the web level without first activating publishing at the site collection level you will receive the following error message:

Element Manifests
The element manifest is used to include both individual resource files such as images, css files, master pages, page layouts and element files which tell SharePoint where to copy files or what to configure once the feature was activated.
The element manifest is where the work gets done. Read about what you can install with features for the full list of possiblities.
Custom Properties
By defining properties within your feature XML you can make your features configurable and use those configuration properties in your feature activation code. The feature properties XML looks like this:
<Properties> <Property Key="Color" Value="Blue"/> <Property Key="Shape" Value="Triangle"/> </Properties>
Here’s how you utilize these feature properties in your feature activation code:
public override void FeatureActivated(SPFeatureReceiverProperties properties) { string colorProperty = properties.Feature.Properties["Color"].Value; string shapeProperty = properties.Feature.Properties["Shape"].Value; // main code here }
4 Responses so far
Dan Marth
May 19th, 2009
7:28 am
What about deploying an ASPX page into the features folder but don’t allow SharePoint Designer edits?
Or is the only way to achive this is to deploy your ASPX page to the layouts directory?
Dan Marth
May 19th, 2009
7:30 am
It took my bloody code out…….
Type=”Ghostable”
creerysmure
May 24th, 2009
8:01 am
Hi, nice posts there
express’s for the compelling dirt
Cory
May 28th, 2009
7:57 am
There are also ways to deploy aspx pages to either a document library or directly to a folder within the site. Much in the same way that a site definition deploys the default.aspx.
As far as disabling SharePoint designer read this blog from the SharePoint Designer team. http://blogs.msdn.com/sharepointdesigner/archive/2008/11/25/locking-down-sharepoint-designer.aspx
Leave a comment