Advanced Feature Development - PowerPoint PPT Presentation

About This Presentation
Title:

Advanced Feature Development

Description:

Activate/Deactivate. Stored in the Hive. 12TEMPLATEFEATURES. Separate directory for each ... Automatically Deactivated when the last Dependency is Deactivated ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 28
Provided by: erikr155
Category:

less

Transcript and Presenter's Notes

Title: Advanced Feature Development


1
Advanced Feature Development
  • Neil Iversen
  • Inetium
  • http//justaddcode.com

2
The Plan
  • Feature Refresher
  • Feature Limitations
  • Custom Actions
  • Dealing with Dependencies
  • Stapling
  • Managing Files
  • Feature Receivers
  • Some Techniques
  • Questions

3
Feature Refresher
  • Deployment vehicle for SharePoint applications
  • The Goal
  • Setup.exe style deployment
  • The Reality
  • Not exactly

4
Feature Refresher
  • Ability to customize SharePoint
  • Used extensively by SharePoint itself
  • Actions
  • Install/Uninstall
  • Activate/Deactivate
  • Stored in the Hive
  • 12\TEMPLATE\FEATURES
  • Separate directory for each feature
  • Scopes
  • Web, Site, Farm, Web App
  • Common Scenarios
  • List Templates
  • Workflow

5
Key Feature Limitations
  • Limited set of supported schemas
  • Supports fewer file options than Solutions
  • Must be bundled in Solutions for larger farms
  • Upgrading deployed features is difficult
  • Might not follow expected behavior

6
Feature Lifecycle
7
Mentioning Solutions
  • Bundled into one file (.wsp)
  • Can combine multiple features
  • Deploys across all web front ends
  • Can easily update SafeControls in web.config
  • Deploy Code Access Security (CAS)

8
Custom Actions
  • Create your own menu options
  • Many extensibility points
  • Main Attributes
  • Title
  • Location
  • GroupId
  • Sequence
  • HideCustomAction
  • Hides an existing Custom Action

9
Custom Actions
  • URL Prefixes
  • site Relative link to the SPWeb
  • sitecollection Relative link to the SPSite
  • URL Replacements
  • ItemId List Items ID
  • ItemUrl List Item URL
  • ListId ID of the List
  • SiteUrl Like site except it can be used
    anywhere
  • Example
  • ltCustomAction
  • Id"325b7c78-f041-4d1b-856b-f9b1e49ddfeb"
  • GroupId"PersonalActions"
  • Location"Microsoft.SharePoint.StandardMen
    u"
  • Sequence"1000"
  • TitleMy Title"
  • DescriptionA Custom Action
  • ltUrlAction Urljavascriptalert(You were at
    SiteUrl)"/gt
  • lt/CustomActiongt

10
Managing Files in Features
  • Deploy a file into a site
  • Web
  • Document Library
  • URL can be aliased
  • MobileRedirect (\m) uses it
  • Not as powerful as Solutions
  • Uninstall behavior is non-intuitive
  • Example
  • ltElements xmlns"http//schemas.microsoft.com/shar
    epoint/"gt
  • ltModule Namefile" Url Path"gt
  • ltFile UrlMyFile.aspx" /gt
  • lt/Modulegt
  • lt/Elementsgt

11
DEMO Features and Files
12
Dealing with Dependencies
  • Problem Feature depends on another SharePoint
    Object
  • Solution Create dependency between the features
  • Example
  • ltActivationDependenciesgt
  • ltActivationDependency FeatureId"52890518-036f-
    4027-babd-f4c7df3ee429" /gt
  • ltActivationDependency FeatureId"6d276cfc-1c84-
    46cc-8566-500e66213e06 " /gt
  • lt/ActivationDependenciesgt

13
Dependency Limitations
  • Feature Chains
  • Limited to one visible feature
  • Dependencies cant be triggered at a higher scope
  • Ex Farm Feature cant depend on a Web Feature
  • Features cant be automatically activated at
    different scopes
  • Ex Web Feature cant activate a Farm Feature
  • Hidden Features
  • Automatically Activated for Dependencies
  • Automatically Deactivated when the last
    Dependency is Deactivated
  • Cant be depended on in different scopes
  • Cant have their own dependencies
  • Can add an additional level to Feature Chains

14
Stapling
  • Problem Cant customize out of the box Site
    Definitions
  • Solution Stapling!
  • Scopes Farm, Web App, Site
  • Note Not Web
  • FeatureSiteTemplateAssociation
  •  ltFeatureSiteTemplateAssociation
    Id"b04e59b1-2c21-48fa-9497-470b1ab711b0"
    TemplateName"STS0" /gt 
  • ltFeatureSiteTemplateAssociation
    Id"fd45b13f-6334-4bce-b87c-49e3f820a74c"
    TemplateNameGLOBAL0" /gt

15
(No Transcript)
16
DEMO Stapling in Action
17
Feature Receivers
  • The Custom Feature
  • .NET Code
  • Override
  • FeatureInstalled, FeatureUninstalling
  • FeatureActivated, FeatureDeactivating
  • Example
  • ltFeature Id"0a7e1ca9-ee71-4407-80a0-b5b57f4f6f5d"
  • TitleMy Feature Reciever"
  • Scope"Site"
  • ReceiverAssemblyMyAssembly, Version1.0.0.0,
    Cultureneutral, PublicKeyTokene35a4d2663eae0ae"
    ReceiverClassMyAssembly.MyFeatureReciever"
  • xmlns"http//schemas.microsoft.com/sharepoint/"gt

18
Feature Receivers Getting Context
  • Getting Context
  • Retrieving the Current Scoped Object
  • SPFeatureReceiverProperties
  • SPFeatureReceiverProperties.Feature.Parent
  • Cast to the appropriate type
  • Scope Web
  • SPWeb web (SPWeb)properties.Feature.Parent
  • SPSite site (SPSite)properties.Feature.Parent
  • Example Usages
  • Perform clean uninstalls of features
  • Upgrade features using Activate
  • Set dependencies to chain actions together
  • Web.config changes
  • Address gaps in current supported Features
  • Policies, Custom Fields,

19
Feature Receivers - Debugging
  • Based on Deployment/Activation Method
  • Stsadm
  • Runs as currently logged in user
  • Console.WriteLine
  • Web Interface
  • Runs as App Pool user
  • Need to use logger (EventLog, or some Logging
    code)
  • DLL Deployment
  • Overwrite Existing DLL
  • iisreset

20
Feature Properties
  • Configuration for your Feature
  • Allow different values for Dev/Test/Prod
  • Combine with scoped property bags to set
    configurations
  • Example
  • ltPropertiesgt
  • ltProperty KeyMyKey" Value123" /gt
  • ltProperty KeyDBServer" Valueprodsql001" /gt
  • lt/Propertiesgt

21
DEMO Deploying SPWeb Properties
22
Manually Activating Features
  • Why?
  • Evade chaining restrictions (at your own peril)
  • Working with Hidden Features
  • Manage Stages of a Site with a Web Part
  • Creating a Suicide Feature

23
Manually Activating Features
  • Get your Context
  • Ex SPWeb
  • Find the Feature Collection
  • Ex SPWeb.Features
  • Find the Features Guid
  • Ex Guid featureGuid new Guid(0a7e1ca9-ee71-440
    7-80a0-b5b57f4f6f5d)
  • Activate!
  • Ex SPWeb.Features.Add(featureGuid)

24
DEMO Feature Activation
25
Your Feedback is Important
  • Please fill out a session evaluation form and
    either put them in the basket near the exit or
    drop them off at the conference registration
    desk.
  • Thank you!

26
Questions?
27
Thanks!
  • Other Sessions
  • SharePoint 212 Customizing the Mobile
    Experience
  • When Thursday 1115am
  • Where Mandalay Bay B
  • SharePoint 314 PowerShell for SharePoint
    Developers
  • When Thursday 2pm
  • Where Mandalay Bay B
  • Neil Iversen
  • Inetium
  • http//justaddcode.com
Write a Comment
User Comments (0)
About PowerShow.com