Convert a site template manifest.xml file to onet.xml site definition file


 <ul style="margin-top: 0in; margin-bottom: 0in; margin-left: 0.015in; direction: ltr;
unicode-bidi: embed”>

I was doing some work for a client and was thinking…. Site definitions are great.
They are extremely flexible. But, they can also be very time consuming to create.
Site templates are a little less desirable because they un-ghost pages. But, they
are so easy and quick to create. It would sure be nice if I could simply take a
site template and convert it to a site definition. Well, it turns out that it’s
not all that hard. There are quite a few steps to follow, but it’s a lot easier
than creating a site definition from scratch.

 

First, let’s get some prep-work done.

 

<ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”1″>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Open the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>ONET.XML<span style="font-size: 11pt;
    font-family: Calibri”> file in the site definition from which the template
    manifest.xml<span
    style=”font-size: 11pt; font-family: Calibri”> file was created and copy it to a
    destination directory

    Important:<span
    style=”font-size: 11pt; font-family: Calibri”> Never modify the default ONET.XML
    files distributed with SharePoint.

    Now that our source and target files are setup, we can begin migrating our list
    definitions.

     

  • <span
    style=”font-size: 11pt; font-family: Calibri”>For each <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/ListTemplates/ListTemplate
    element already present in the file,
    make sure to set the

    /Project/ListTemplates/ListTemplate[Path]

    attribute to the folder under the Lists directory where the original site definition
    resides. For example, if referencing lists from the default Team Web Site site definition,
    set the

    /Project/ListTemplates/ListTemplate[Path]

    attribute to

    “STS”
    .

     

  • <span
    style=”font-size: 11pt; font-family: Calibri”>For each <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Web/UserLists/List<span style="font-size: 11pt;
    font-family: Calibri”> elements in the <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>manifest.xml
    file, add a

    /Project/ListTemplates/ListTemplate

    element to the destination
    <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>ONET.XML
    file

    Note:<span
    style=”font-size: 11pt; font-family: Calibri”> The next few steps describe the formatting
    for each
    /Project/ListTemplates/ListTemplate

    element. Each new ListTemplate element will take this form:

    <ListTemplate Name=”Cache” DisplayName=”Cache” Type=”10000″ BaseType=”0″ Unique=”TRUE”
    Hidden=”TRUE” DontSaveInTemplate=”TRUE” SecurityBits=”11″ Description=”List of meetings
    attached to the workspace.” Image=”/_layouts/images/itgen.gif”></ListTemplate>

    I will refer to attributes from the
    /Web/UserLists/List<span
    style=”font-size: 11pt; font-family: Calibri”> element we are converting through
    the List[@source_attribute]<span
    style=”font-size: 11pt; font-family: Calibri”> notation and to attributes of the
    /Project/ListTemplates/ListTemplate
    we are generating through
    the
    ListTemplate[@target_attribute]<span
    style=”font-size: 11pt; font-family: Calibri”> notation.

    Note:<span
    style=”font-size: 11pt; font-family: Calibri”> We are adding additional
    /Project/ListTemplates/ListTemplate
    elements to the new
    ONET.XML<span
    style=”font-size: 11pt; font-family: Calibri”> file. We are not removing the default
    /Project/ListTemplates/ListTemplate
    elements already present
    in the file.

    Note:<span
    style=”font-size: 11pt; font-family: Calibri”> We are creating list definition headers
    in the ONET.XML file, but we have not yet created the list schemas behind the new
    list definitions. For detailed steps on converting the list definition from the
    site template manifest.xml to a site definition schema.xml file, take a look at
    my previous blog entry.

     

  • <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”a”>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>ListTemplate[Name]<span style="font-size: 11pt;
    font-family: Calibri”> to <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>List[Title].
    Make sure to remove any non-alpha characters from when converting the title to the
    list name. For example, if the Title is
    <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>”My Mom’s List”,
    set the name to something like
    <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>”MyMomsList”.
  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>ListTemplate[Name]<span style="font-size: 11pt;
    font-family: Calibri”> to <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>List[DisplayName].
  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>ListTemplate[Type]<span style="font-size: 11pt;
    font-family: Calibri”> to<span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”> a
    unique numeric value. I, and others, recommend starting at 10000.

    Note:<span
    style=”font-size: 11pt; font-family: Calibri”> Although the
    Type<span
    style=”font-size: 11pt; font-family: Calibri”> attribute is optional in the
    ONET.XML<span
    style=”font-size: 11pt; font-family: Calibri”> file, you will not be able to automatically
    provision the list using <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>Configuration
    elements upon site creation unless you specify the
    <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>Type
    attribute.

     

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>ListTemplate[Description]<span style="font-size: 11pt;
    font-family: Calibri”> to <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>List[Description].
  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set<span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”> ListTemplate[BaseType]<span style="font-size: 11pt;
    font-family: Calibri”> to <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>List[BaseType].
  •  

    <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”1″>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Leave the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/DocumentTemplates<span style="font-size: 11pt;
    font-family: Calibri”> and <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>/Project/BaseTypes
    elements as is.

    With the list definitions migrated, we need to set up a site configuration to provision
    our lists and a couple of modules to define the files and web parts our site will
    use.

     

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Remove the default <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration<span
    style=”font-size: 11pt; font-family: Calibri”> elements from the new
    ONET.XML<span
    style=”font-size: 11pt; font-family: Calibri”> file. We will be creating a new one
    based on the configuring of the site from the site template.

     

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Create a new <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration<span
    style=”font-size: 11pt; font-family: Calibri”> element in the new
    ONET.XML<span
    style=”font-size: 11pt; font-family: Calibri”> file.

     

  • <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”a”>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration[ID]<span
    style=”font-size: 11pt; font-family: Calibri”> to <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>”0″
    .

     

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration[Name]<span
    style=”font-size: 11pt; font-family: Calibri”> to <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>”Default”<span style="font-size: 11pt;
    font-family: Calibri”>.

     

  • <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”1″>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Create a new <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration/Lists<span
    style=”font-size: 11pt; font-family: Calibri”> element.

     

  • <span
    style=”font-size: 11pt; font-family: Calibri”>For each custom <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/ListTemplates/ListTemplate
    created in step 3, create a
    /Project/Configurations/Configuration/Lists/List<span
    style=”font-size: 11pt; font-family: Calibri”> element. You will now need to use
    the optional Type attribute specified in step 3c.

    The newly created elements will take the following forms:

    <List Title=”Cache” Type=”10000″ ></List>

    Note:<span
    style=”font-size: 11pt; font-family: Calibri”> The next steps should be performed
    for each newly created
    /Project/Configurations/Configuration/Lists/List
    <span style="font-size: 11pt;
    font-family: Calibri”> element.

     

  • <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”a”>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration/Lists/List[Title]<span
    style=”font-size: 11pt; font-family: Calibri”> attribute to the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/ListTemplates/ListTemplate[DisplayName]<span
    style=”font-size: 11pt; font-family: Calibri”>.
  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration/Lists/List[Type]<span
    style=”font-size: 11pt; font-family: Calibri”> attribute to <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/ListTemplates/ListTemplate[Type]<span
    style=”font-size: 11pt; font-family: Calibri”>.

     

  • <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”1″>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Add the following elements to the
    /Project/Configurations/Configuration/Lists
    element:

     

  • <List Title=”Site Template Gallery” Type=”111″ Url=”_catalogs/wt” RootWebOnly=”TRUE”></List>

    <List Title=”Web Part Gallery” Type=”113″ Url=”_catalogs/wp” RootWebOnly=”TRUE”></List>

    <List Title=”List Template Gallery” Type=”114″ Url=”_catalogs/lt” RootWebOnly=”TRUE”></List>

     

    <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”1″>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Clear out the old <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration/Modules
    element.

     

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Create a <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Modules<span style="font-size: 11pt;
    font-family: Calibri”> element in the new <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>ONET.XML<span style="font-size: 11pt;
    font-family: Calibri”> file.

     

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Create a <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration/Modules/Module<span
    style=”font-size: 11pt; font-family: Calibri”> element
  • <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”a”>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration/Modules/Module[Name]<span
    style=”font-size: 11pt; font-family: Calibri”> to <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>”DefaultHome”<span style="font-size: 11pt;
    font-family: Calibri”>.
  • <span
    style=”font-size: 11pt; font-family: Calibri”>Set the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Configurations/Configuration/Modules/Module[Name]<span
    style=”font-size: 11pt; font-family: Calibri”> to <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>”WebPartPopulation”<span style="font-size: 11pt;
    font-family: Calibri”>.
  •  

    <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”1″>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Clear out the old <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Modules<span style="font-size: 11pt;
    font-family: Calibri”> element

     

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Create a <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Modules <span style="font-size: 11pt;
    font-family: Calibri”>element in the new <span style="font-weight: bold; font-size: 11pt;
    font-family: Calibri”>ONET.XML
    file.
  •  

    <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”1″>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Add the following element to the
    /Project/Modules<span
    style=”font-size: 11pt; font-family: Calibri”> element:

     

  • <Module Name=”DefaultHome” Url=”” Path=””>

    <File Url=”default.aspx”>

    <NavBarPage Name=”Home” ID=”1002″ Position=”Start”> </NavBarPage>

    </File>

    </Module>

     

    <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”1″>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Add the following element to the
    /Project/Modules
    element:

     

  • <Module Name=”WebPartPopulation” List=”113″ Url=”_catalogs/wp” Path=”..\sts\lists\wplib\dwp”
    RootWebOnly=”TRUE”>

    <File Url=”MSContentEditor.dwp” Type=”GhostableInLibrary”/>

    <File Url=”MSPageViewer.dwp” Type=”GhostableInLibrary”/>

    <File Url=”MSImage.dwp” Type=”GhostableInLibrary”/>

    <File Url=”MSMembers.dwp” Type=”GhostableInLibrary”/>

    <File Url=”MSXml.dwp” Type=”GhostableInLibrary”/>

    </Module>

     

    <ol style="margin-top: 0in; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in;
    direction: ltr; font-family: Calibri; unicode-bidi: embed” type=”1″>

  • <span
    style=”font-size: 11pt; font-family: Calibri”>Leave the <span style="font-weight: bold;
    font-size: 11pt; font-family: Calibri”>/Project/Components <span style="font-size: 11pt;
    font-family: Calibri”>as is.

     

  • At this point we have transferred all of the list definitions from our site template
    to our site definition and created the list schema.xml files to store the schemas
    for our custom lists. However, we have not added the web pats to our default.aspx
    page. Unfortunately, I have run out of time on this post so I will have to leave
    that for another day. In the mean time, I hope this post helps anyone looking for
    a “quick-start” way to create site definitions from existing SharePoint sites.

    2 Comments to “Convert a site template manifest.xml file to onet.xml site definition file”

    1. Hi, great post. Do you know how to specify a specific theme and regional settings in the ONET.XML?

    2. Toby, I have not seen how to do that. You can always fall back on specifying it in code in an ASPX page. You can spcify to run the ASPX page using the ExecuteURL sub-element of the Configuration element.

    Leave a comment