Monday 4 February 2008

Going Down The Rabbit Hole - The MOSS 2007 Publishing Site Definition

It has been well over a year since I started developing on MOSS 2007, I started development with just using SharePoint Designer, and manually deploying assemblies and artifacts without features and solutions.
Soon after I realised the trouble and pain you could get yourself into if you don't use the feature and solution framework. In the aim to work 'fast' and finish your development tasks quickly, you can fall into a massive trap and realise that although it takes plenty of effort to develop Features, in the long term you are better off because of RE-USE of features and ease of DEPLOYMENT. All developers love reusing their work, it saves time in the long run, and you don't have to constantly re-do the same thing like a robot. When you deploy you customisations to a production system, you don't always have SharePoint Designer available to hookup to the site, and you don't want to have to remember a dozen manual steps to repeat, more robot action, it also leaves room for human error, and the Network/Systems Admin guys won't be happy with you, they want an atomic deployment process.
You can go one step further, develop your own Custom Site Definition, so you can allow users to create *custom* sites pre-populated with your Lists and other files, and the sites can have YOUR features enabled AUTOMATICALLY, sounds nice hey?
In the last few months I have been doing just that, so I thought I would document the following to help myself (and now YOU) understand what happens when sites are created in SharePoint and how the Features are enabled.

So what actually happens when you create a new Publishing Site ?Whenever you create any site in SharePoint, XML files in the 12 Hive are used in the process to create the site, the various XML files contain information and settings needed to provision sites as well as references to dependent Features that are also activated on Site Collection creation or Web Creation. The Folder ’12-hive’\TEMPLATE\1033\XML Contains the file webtempsps.xmlThe file contains some of the following related to Publishing Sites, the BLANKINTERNETCONTAINER template is used to create a new Publishing Site Collection
What is VisibilityFeatureDependency ?
There are Feature IDs referenced in the VisibilityFeatureDependency attribute
The F6924D36-2FA8-4f0b-B16D-06B7250180FA Feature ID refers to the PublishingSite feature and Feature ID 97A2485F-EF4B-401f-9167-FA4FE177C6F6 refers to the BaseSiteStapling feature. F6924D36-2FA8-4f0b-B16D-06B7250180FA - PublishingSite
This is the PublishingSite feature. This feature does nothing more than Activate four other features, it has the following ActivationDependencies
More feature IDs to lookup !A392DA98-270B-4e85-9769-04C0FDE267AA - PublishingPrerequisites
This is the PublishingPrerequisites feature which hooks up a Feature Event receiver. AEBC918D-B20F-4a11-A1DB-9ED84D79C87E - PublishingResources
This is the PublishingResources feature which provisions Site Columns, Content Types, Files and Resource settings
89E0306D-453B-4ec5-8D68-42067CDBF98E - Navigation
This is the Navigation feature which provisions custom actions and controls for Navigation D3F51BE2-38A8-4e44-BA84-940D35BE1566 - PublishingLayoutsThis is the PublishingLayouts feature which provisions files into the site. It provisions all Publishing Page Layouts, Master Pages, Page Layout Preview Images, Style library Images and Style Library CSS 97A2485F-EF4B-401f-9167-FA4FE177C6F6 - BaseSiteStapling
This is the BaseSiteStapling feature, it will staple several features to site definitions listed in the feature, it contains dozens of FeatureSiteTemplateAssociation nodes, it is interesting to note that :
Feature B21B090C-C796-4b0f-AC0F-7EF1659C20AE (BaseSite) is stapled to the following site templates :STS#0 , STS#2 , MPS#0 , MPS#1 , MPS#2 , MPS#3 , MPS#4 , WIKI#0 , BLOG#0 , BDR#0 , EAWF#0 , OFFILE#0 , OFFILE#1 , PWA#0 , PWS#0 , SPS#0 , SPSMSITE#0 , SPSTOC#0 , SPSTOPIC#0 , SPSNEWS#0 , SPSNHOME#0 , SPSSITES#0 , SPSBWEB#0 , SPSCOMMU#0 , SPSREPORTCENTER#0 , SPSPORTAL#0 , SRCHCEN#0 , PROFILES#0 , CMSPUBLISHING#0
The BaseSite Feature is an ActivationDependency feature and activates the following Features LocalSiteDirectorySettingsLink Feature LocalSiteDirectoryControl Feature PortalLayouts Feature WebPartAdderGroups Feature
Feature 99FE402E-89A0-45aa-9163-85342E865DC8 (BaseWeb) is stapled to the following site templates :STS#0 , STS#2 , MPS#0 , MPS#1 , MPS#2 , MPS#3 , MPS#4 , WIKI#0 , BLOG#0 , BDR#0 , EAWF#0 , OFFILE#0 , OFFILE#1 , PWA#0 , PWS#0 , SPS#0 , SPSMSITE#0 , SPSTOC#0 , SPSTOPIC#0 , SPSNEWS#0 , SPSNHOME#0 , SPSSITES#0 , SPSBWEB#0 , SPSCOMMU#0 , SPSREPORTCENTER#0" , SPSPORTAL#0 , SRCHCEN#0 , PROFILES#0 , CMSPUBLISHING#0
The BaseWeb Feature is also an ActivationDependency feature and activates the following Features
RelatedLinksScopeSettingsLink Feature AnalyticsLinks Feature FeatureStapling Feature

Feature 541F5F57-C847-4e16-B59A-B31E90E6F9EA (NavigationProperties) is stapled to the SRCHCENTERLITE#1 site template with the following properties within the FeatureSiteTemplateAssociation




Which explains why the Search Centre Lite Navigation is different to navigation in all other site templates!
We have now traced through the VisibilityFeatureDendencies in webtempsps.xml, let us now get back to this file and continue this journey down the rabbit hole by exploring the SiteTemplates referenced.
The Folder ’12-hive’\TEMPLATE\SiteTemplates Contains a folder for each Site Template in the site. One such folder is BLANKINTERNET which contains an XML folder that contains a ONET.xml file.
This file contains the following configuration nodes, which contain Feature ids, so even more features can be activate on site creation, there are Site Features activated on Site Collection Creation and Web Features activated on Web (sub-site) Creation. NOTE : THIS SPECIFIC CONFIGURATION HAS SITE FEATURES AND WEB FEATURES Publishing Site Features
The following are site features activated on Site Collection creation
C85E5759-F323-4EFB-B548-443D2216EFB5 ExpirationWorkflow Feature
02464C6A-9D07-4F30-BA04-E9035CF54392 ReviewWorkflows Feature6C09612B-46AF-4B2F-8DFC-59185C962A29 SignaturesWorkflow FeatureC6561405-EA03-40A9-A57F-F25472942A22 TranslationWorkflow FeatureA392DA98-270B-4e85-9769-04C0FDE267AA PublishingPrerequisites Feature7C637B23-06C4-472d-9A9A-7C175762C5C4 ViewFormPagesLockDown FeatureAEBC918D-B20F-4a11-A1DB-9ED84D79C87E PublishingResources FeatureF6924D36-2FA8-4f0b-B16D-06B7250180FA PublishingSite Feature7AC8CC56-D28E-41f5-AD04-D95109EB987A OSSSearchCenterUrlSiteFeature Feature Publishing Web Features
The following is a list of all Web Features in the onet.xml file00BFEA71-DE22-43B2-A848-C05709900100 CustomList Feature00BFEA71-E717-4E80-AA17-D0C71B360101 DocumentLibrary Feature00BFEA71-52D4-45B3-B544-B1C71B620109 PictureLibrary Feature00BFEA71-A83E-497E-9BA0-7A5C597D0107 TasksList Feature00BFEA71-4EA5-48D4-A4AD-305CF7030140 WorkflowHistoryList Feature22A9EF51-737B-4ff2-9346-694633FE4416 Publishing Feature541F5F57-C847-4e16-B59A-B31E90E6F9EA NavigationProperties Feature94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB PublishingWeb Feature
Summary

This investigation demonstrates what actually happens when you create a publishing site in MOSS 2007. In summary, a series of features are enabled on the site collection, in a specific order. Features are also enabled when creating subsites.Why do we need this information ?

To create YOUR OWN Custom Publishing Site Definitions, so you have full control over what features are activated in your site, you can get into trouble if you do not activate features in the correct order, such as activating a feature that contains Page Layouts referencing a Content Type, if the Page Layout feature is enabled before the Content Type feature then the pages created will not be created correctly because of the dependency issue.

2 comments:

Anonymous said...

Excellent post,
I finally have my auto-activation working after taking the time to go through your explanation
Thanks
Andy

Sezai Komur said...

Happy to help - post looks bad with xml and code pasted in and not formatted corectly.

Glad you could get a sense of the explanation :)