250 likes | 797 Views
SharePoint Development 101: Feature Design. By Becky Isserman http://www.mosslover.com. SharePoint Development vs. ASP .Net Development. User Controls Features. Build a User Control using the SharePoint Object Model. Demo. What is a Feature?.
E N D
SharePoint Development 101: Feature Design By Becky Isserman http://www.mosslover.com
SharePoint Development vs. ASP .Net Development • User Controls • Features
What is a Feature? • Re-usable solutions on the farm, web application, site collection (site), and site (web) level • Have endless possibilities for use… • Requires a Feature.xml (feature definition file) • Can have an Elements.xml or more • Are stored in 12\template\features
Answer: 137 Question: How many features are installed in SharePoint out of the box?
Feature Definition (feature.xml) • Includes: • Elements Attributes • Activation Dependencies • Feature Elements (included in elements.xml files)
Feature Definition Example <Feature Title = “My Feature” Scope = “Web” Id=“235A5BAD-7D97-435C A2DB-AB579CAD79BC” Version = “2.3.1.2” xmlns = “http://schemas.microsoft.com/sharepoint”> <ElementManifests> <ElementManifest Location=“Elements.xml” /> </ElementManifests> </Feature> Bonus: What do these attributes mean?
Activation Dependencies • Definition: Requirement in the relationship between two features • Can be on the same scope or cross-scope • Between two separate scope • i.e. Web to Site, Site to Web Application, or Web Application to Farm • Used to guarantee resources or group features together
The Team Collaboration Site Definition Activates 19 features can you name some of them?
Feature Receivers • FeatureInstalled • FeatureUninstalling • FeatureActivated • FeatureDeactivating • Good Reference STSDEV Video with Ted Pattison
Solution Package • Feature.xml and Elements.xml files • Manifest.xml • GUID • Tells feature if it should be deployed on WFE’s, Application Server, etc… • Lists Safe Controls • Diamond Directive File (ddf) • Place to include files and directories for solution package • .Set DestinationDir=Directory • To manually create Feature Package (wsp file):MakeCab.exe /F DeploymentFiles\Test.ddf /D CabinetNameTemplate=Feature.wsp /D DiskDirectory1=wsp
Solution Package • Dynamically create a feature package by creating Test.targets file • Add some xml to point to MakeCab.exe and add command shell • Right click on the solution in Solution Explorer and select “Unload Project” • Right click the project name in solution explorer and select Edit [project name].csproj • Add to end: <Import Project = “DeploymentFiles\Test.targets” /> • Delete all commented xml, but <Target Name=“AfterBuild”></Target> • Add:<Target Name = “AfterBuild”><CallTarget Targets = “Test” /></Target> • Save Changes and Right Click on the project name and choose “Load” (you may see a warning dialog box, ignore it)
Manual Installation and Activation • All Features must be installed before they can be activated • All features must be deactivated before they can be uninstalled, unless scope is farm or web app
Manual Installation and Activation stsadm.exe –o installfeature{-filename <relative path to Feature.xml> | -name <feature folder>} [-force] stsadm.exe –o uninstallfeature {-filename <relative path to Feature.xml> | -name <feature folder> | -id <feature Id>} [-force] stsadm.exe –o activatefeature {-filename <relative path to Feature.xml> | -id <feature id>} [-url <url>] [-force] stsadm.exe –o deactivatefeature {-filename <relative path to Feature.xml> | -id <feature id>} [-url <url>] [-force]
Feature Disadvantages • Before STSDev you had to manually create the manifest, ddf files, feature.xml, elements.xml, solution installer, etc… • Deactivating and retracting features leave artifacts • Not all lists, content types, and columns leave when the feature is turned off • Can still remove items manually • Some people do not like coding only in xml • XML intellisense was just added in the new SDK for SharePoint • There is no debugger • There is no pretty design interface
Feature Advantages • Easy to deploy in multiple environments and sites • Creates items as un-customized • i.e. master pages can reside in one place and include 3 references, rather than normally where SharePoint Designer creates 3 separate master pages • Can control site columns and content types • Harder to track if created individually in user interface • Overall a lot of time is saved, which equals $$
Tools • STSDev • http://www.codeplex.com/stsdev • VSEWSS 1.1 (Visual Studio Extensions for Windows SharePoint Services) • http://www.microsoft.com/downloads/details.aspx?FamilyID=3e1dcccd-1cca-433a-bb4d-97b96bf7ab63&displaylang=en • Andrew Connell CodeRush/Refactor Tool for Developershttp://www.andrewconnell.com/blog/articles/ProductivityToolsForSharePointDevelopers.aspx • SharePoint for Developer's Part 1: http://msdn.microsoft.com/en-us/rampup/dd221355.aspx
References • Professional SharePoint 2007 Developmentby John Holliday, et al. pages 138-158 • Microsoft SharePoint Server 2007 Bible by Wynne Leon, et al. pages 255-283 • Real World SharePoint 2007 b Scot Hillier, et al. pages 96-111 • Professional SharePoint 2007 Web Content Management Development by Andrew Connell pages 63-67
Contact Information • Blog: http://www.mosslover.com • E-Mail: rebecca.isserman@gmail.com • SharePoint Comic: http://www.sharepointcomic.com • Kansas City Office Geeks Site: http://www.officegeeks.org/kcog