Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .
-
date post
18-Dec-2015 -
Category
Documents
-
view
215 -
download
0
Transcript of Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .
![Page 1: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/1.jpg)
Packaging Your Advanced SharePoint Customizations
Neil Iversen
Inetium
http://justaddcode.com
![Page 2: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/2.jpg)
Solution Basics
• At its core, a solution pushes files around● The File Bus of SharePoint
• ‘Farm Safe’ – Works across Front Ends
• Deployed to the Farm
![Page 3: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/3.jpg)
Solution Life Cycle – High Level
![Page 4: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/4.jpg)
Features
• Deployable unit of functionality
• Used to customize SharePoint
• Extensively used by SharePoint itself
• Stored in the Hive● 12\TEMPLATE\FEATURES● Each feature in its own directory
![Page 5: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/5.jpg)
Feature Lifecycle
![Page 6: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/6.jpg)
Types of Features
• Content Type• Custom Action• Delegate Controls• Events• Feature Stapling• Field• Lists (Templates and Instances)• Module• Workflow
![Page 7: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/7.jpg)
Why do I need this fancy packaging?
• You need something that isn’t available in the OOB Features
• The OOB Features do/don’t do something you need
• You are deploying something outside of SharePoint
• And you still care about change control
![Page 8: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/8.jpg)
Developer Alice
Developer Bob
Developer Charlie
Developer Merge
Stage Prod
Individual Developer Environments● Developers build functionality into
features/solutions
![Page 9: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/9.jpg)
Feature Receivers
• Executes code when the state changes• Key to our ability to make drastic changes
● “If you can code it you can do it”• Allows for extremely powerful code to get added
● While still being easily deployable● Overrides
• FeatureInstalled, FeatureUninstalling• FeatureActivated, FeatureDeactivating
• Example● <Feature Id="0a7e1ca9-ee71-4407-80a0-b5b57f4f6f5d"
Title=“My Feature Reciever" Scope="Site" ReceiverAssembly=“MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e35a4d2663eae0ae" ReceiverClass=“MyAssembly.MyFeatureReciever" xmlns="http://schemas.microsoft.com/sharepoint/">
![Page 10: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/10.jpg)
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
![Page 11: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/11.jpg)
Scopes
• Farm
• Web App
• Site
• Web
WFE A Extranet WFE
http://sitecollection
http://sitecollection/deptA
http://sitecollection/deptB
WFE B
Indexer
http://external
http://external/clientA
Database
![Page 12: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/12.jpg)
Demo: Our first Custom Feature
![Page 13: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/13.jpg)
Feature Receivers - Debugging
• Based on Deployment/Activation Method• Stsadm
● Runs as currently logged in user● Debug/Console.WriteLine● System.Diagnostics.Debugger.Launch();
• Web Interface● Runs as App Pool user● Need to use logger (EventLog, or some Logging code)● Attach to w3wp.exe
• DLL Deployment● Overwrite Existing DLL● iisreset● stsadm –o activatefeature -force
![Page 14: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/14.jpg)
Testing Your Code
• Unit Testing Features● Pretty straight forward if you Develop on a
SharePoint environment● Probably want to ignore your abstraction
violations (SharePoint mocks are tough)
• Always test Farm/Scope safety● Need a multi server environment● Can you make it part of your build?
![Page 15: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/15.jpg)
Feature Object Model
• SPFarm.FeatureDefinitions
• SPSite.Features
• SPWeb.Features
• SPFeature● SPFeatureDefinition
![Page 16: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/16.jpg)
Demo: Exploring the Feature OM
![Page 17: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/17.jpg)
Feature Properties
• Configuration for your Feature• Allow different values for Dev/Test/Prod• Combine with scoped property bags to set
configurations• Example
<Properties><Property Key=“MyKey" Value=“123" /><Property Key=“DBServer" Value=“prodsql001" />
</Properties>
![Page 18: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/18.jpg)
Demo: Working with Properties
![Page 19: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/19.jpg)
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’
![Page 20: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/20.jpg)
Manually Activating a Feature
• Get your Context● Ex: SPWeb
• Find the Feature Collection● Ex: SPWeb.Features
• Find the Feature’s Guid● Ex: Guid featureGuid = new Guid(“0a7e1ca9-ee71-
4407-80a0-b5b57f4f6f5d”)• Activate!
● Ex: SPWeb.Features.Add(featureGuid)
![Page 21: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/21.jpg)
Demo: Manually Activating Features
![Page 22: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/22.jpg)
Feature Properties
• Configuration for your Feature• Allow different values for Dev/Test/Prod• Combine with scoped property bags to set
configurations• Example
<Properties><Property Key=“MyKey" Value=“123" /><Property Key=“DBServer" Value=“prodsql001" />
</Properties>
![Page 23: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/23.jpg)
Demo: Working with Properties
![Page 24: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/24.jpg)
Dependencies and Features
• Your Feature might need to assume another feature is already active
• Make several smaller features, then wrap them into a single feature that is dependant on them
• Dependencies can only be one level deep• Example
● <ActivationDependencies> <ActivationDependency FeatureId="52890518-
036f- 4027-babd-f4c7df3ee429" /> <ActivationDependency FeatureId="6d276cfc-
1c84- 46cc-8566-500e66213e06 " /></ActivationDependencies>
![Page 25: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/25.jpg)
Dependency Limitations
• Feature Chains● Limited to one visible feature
• Dependencies can’t be triggered at a higher scope● Ex: Farm Feature can’t depend on a Web
Feature
• Features can’t be automatically activated at different scopes● Ex: Web Feature can’t activate a Farm
Feature
![Page 26: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/26.jpg)
Feature Dependency
Web Site App Farm
Web
Site
App
Farm
ParentDependant
![Page 27: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/27.jpg)
![Page 28: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/28.jpg)
Hidden Feature
![Page 29: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/29.jpg)
Hidden Feature – Activate Child
1.
2.
![Page 30: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/30.jpg)
Hidden Feature - Deactivate
2.
1.
![Page 31: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/31.jpg)
Hidden Feature - Deactivate
3.
1. 2.
![Page 32: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/32.jpg)
Demo: Dependencies are Tasty!
![Page 33: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/33.jpg)
Putting it Together
• Problem: Modifying the web.config in a Farm Safe manner
• Solution: SPWebConfigModification and Features● SPWebConfigModification is Farm Safe● Scoping does become an issuee
![Page 34: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/34.jpg)
• Not for the faint of heart!
![Page 35: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/35.jpg)
Demo: Farm Safe Web.config
![Page 36: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/36.jpg)
Getting a little crazy
• What about non-SharePoint assets?● Databases, other web sites, …
• Is there an advantage?● Depends on reason for creating the Feature● Most common is Devs can’t touch Prod
![Page 37: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/37.jpg)
Other Interesting Approaches
• Manually Deploy across a Farm● Create your own Timer Jobs● Manually add them to the different WFEs
• PowerShell ‘Feature’● Execute PowerShell via a Feature
• PowerShell v2 Scripts● Has ability to execute remote commands
![Page 38: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/38.jpg)
Demo: Deploying SQL Components
![Page 39: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/39.jpg)
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!
![Page 40: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/40.jpg)
Questions?
![Page 41: Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium .](https://reader038.fdocuments.in/reader038/viewer/2022103123/56649d245503460f949fb138/html5/thumbnails/41.jpg)
Thanks!
Neil Iversen
Inetium
http://justaddcode.com