SharePoint Site Configurator Feature V2.0 Released

 

I am happy to announce the release of SharePoint Site Configurator Updated for SharePoint 2010 and packed with a lot of new features!

 

Why Site Configurator?

There were three main reasons for creating the Site Configurator feature:

1. In some scenarios there is a need for being in as much control of the site provisioning process as possible; making sure what gets created in what order.

2. A wish to reuse as much custom functionality as possible.

3. Making site provisioning as easy as possible, because sometimes developers found it hard to use and understand the built-in provisioning mechanisms.

Provisioning site process of SharePoint

The term provisioning is used to describe the process of creating a new SharePoint site and making it available for end-users. There are several steps in the creation process and SharePoint provisions in the following order:

    1. Global onet.xml
      This file defines list templates for hidden lists, list base types, a default definition configuration, and modules that apply globally to the deployment.
    2. SPSite scoped features defined in site definitions onet.xml, in the order they are defined in the file.
      The onet.xml file defined in the site definition can define navigational areas, list templates, document templates, configurations, modules, components, and server e-mail footers used in the site definition to which it corresponds.
    3. SPSite scoped stapled features, in quasi random order
    4. SPWeb scoped features defined in onet.xml, in the order they are defined in the file.
    5. SPWeb scoped stapled features, in quasi random order
    6. List instances defined in onet.xml
    7. Modules defined in onet.xml

This is a fairly complex process and it can often be hard to know the method for customizing a site definition. A solution can be right in one scenario and completely wrong in another, making this somewhat confusing.

If you want to catch up on site definitions or other parts of this process take a look at the following links, Site definitions and configurations and How to: Create a Custom Site Definition and Configuration.

Provisioning with Site Configurator

Process overview

Site Configurator is attaching to step 5, as a web stapled feature, as late in the out-of-the-box (OOB) provisioning as possible. Omitting steps 2, 3 and 4 is also recommended and will be the case if you use the blank site definition template as a starting point.

Once the Site Configurator is activated, it reads a siteconfigurations.xml file from its feature folder. The file consists of configuration elements, ie. custom settings, web parts, list instances, other features to activate, and then configures your site according to the specifications.

In order to make Site Configurator handle customization of your site, you need to complete three steps with an optional fourth:

1. Create a Site Configurator feature

2. (Optional) Create a new site definition

3. Staple the Site Configurator feature to a site definition.

4. Deploy and create a new site.

Make sure you generate and use your own IDs for the features you create!

1. Create a Site Configurator feature

The Site Configurator needs to be triggered to start making the configurations of your site. A feature receiver is used as this trigger. The feature simply points to the feature receiver in the “sharepointsiteconfigurator.dll”:

<?xml version="1.0" encoding="utf-8" ?>

<Feature xmlns="https://schemas.microsoft.com/sharepoint/"

ReceiverAssembly="SiteConfigurator, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4d009ee268a83a6d"

ReceiverClass="SharePointSiteConfigurator.SiteConfigurator_FeatureEventReceiver" Scope="Web">

<ElementManifests>
<ElementFile Location="SiteConfigurations.xml" />
  </ElementManifests>

</Feature>

Also, this feature must contain the “siteconfigurations.xml” file, which defines the configurations to apply. A minimal example:

<?xml version="1.0" encoding="utf-8" ?>

<SiteConfigurations xmlns="https://tempuri.org/siteconfigurator.xsd">

<SiteConfiguration Name="SITEDEFINITIONEXAMPLE#0">

<ApplyTheme Id="Simple"/>

</SiteConfiguration>

</SiteConfigurations>

This configuration will apply the theme “Simple” to a new site, if the site is made from the site definition “SITEDEFINITIONEXAMPLE” and configuration number “0” (“#0”)

2. (Optional) Create a new site definition

Creating a new site definition is described on https://msdn.microsoft.com/en-us/library/ms454677(office.14).aspx

On the Codeplex site we’ve included a sample definition which you can use as a starting point, and this site definition is used as reference in this document.

3. Farm stapling the Site Configurator feature to a site definition

This configuration will apply the theme “Simple” to a new site, if the site is made from the site definition “SITEDEFINITIONEXAMPLE” and configuration

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="https://schemas.microsoft.com/sharepoint/">

<!-- The feature will be stapled (activated) on all sitedefinitions you list here-->

<FeatureSiteTemplateAssociation Id="499bb3bb-9363-4f3d-a96d-1d69948c2cf3" TemplateName="SiteDefinitionExample#0" />

</Elements>

The ID provided here is the ID of the feature to staple, in this instance the ID of the Site Configurator feature created in step 1.

In the solution available on the project site, a Site Configurator feature and a Farm Stapler are included. You should use these files as examples on how to set up your own solution.

4. Deploy and create a new site

After completing these steps, build your solutions in Visual Studio. This will create .wsp files. Either deploy them with use of Visual Studio, PowerShell or STSADM.exe. The deploy will copy the solution(s) to SharePoint and place the siteconfigurator.dll the GAC (Global Assembly Cache ie. c:\windows\assembly) and the features and their configuration files are deployed to the SharePoint 14 catalog (14 hive).

Creating a new site of the type specified in step 3, will now trigger the Site Configurator and configure the site according to the specifications in the siteconfigurations.xml file.

 

For more information go to the SharePoint Site Configurator site.