SharePoint allows developers to create solutions and deploy to its platform. One way to deploy a solution and manage it is using feature. Feature is a combination of several elements that can be turned on or off at various levels or scope.
- Farm scope (Farm)
- Web application scope (WebApplication)
- Site Collection scope (Site )
- Web site scope (Web)
Feature is physically a xml file named feature.xml. Feature is accompanied by an elements file, commonly named elements.xml. This file name can be anything as long as it is reflected properly in feature.xml file. The feature.xml file specifies name of the feature and its scope as well as the name of the elements file. Elements file can have custom actions and modules that are part of this feature to be deployed. A feature can also receive events such as feature activated or deactivated.
Following are the steps to create a feature and deploy it manually -
- Create a class library project
- Create appropriate folder structure, for example
- Templates
- Feature
- CustomFeature
- Feature
- Templates
- Add two files, example below
- Feature.xml
1: <Feature
2: Id="EEC24C3D-B14A-4c4b-8673-5E196E7DDA17"
3: Title="My Custom Feature"
4: Description=""
5: Scope="Web"
6: Hidden="false"
7: ImageUrl="TPG\binoculars.gif"
8: xmlns="http://schemas.microsoft.com/sharepoint/">
9: <ElementManifests>
10: <ElementManifest Location="elements.xml"/>
11: </ElementManifests>
12: </Feature>
- Elements.xml
1: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
2: <Module Path="PageTemplates" Url="SitePages" >
3: <File Url="MyPage.aspx" Type="Ghostable" />
4: </Module>
5: </Elements>
- Feature.xml
- Add a aspx page mypage.aspx and modify as you wish.
- Sign the project and build
- deploy the dll to GAC
- deploy the feature using stsadm
1: stsadm.exe -o installfeature -filename customfeature\feature.xml -force
No comments:
Post a Comment