Click here to Skip to main content
13,249,512 members (41,233 online)
Click here to Skip to main content
Add your own
alternative version


3 bookmarked
Posted 8 Jun 2011

Custom Site Definition

, 8 Jun 2011
Rate this:
Please Sign up or sign in to vote.
Explains the way I generate custom site definition based on the site template imported in Visual Studio 2010


This post explains the way I generate custom site definition based on the site template imported in Visual Studio 2010.

When we are going to create a new site definition, most SharePoint developers may know that - Make a copy of OOB, and fewer changes on it.


My target is to create a site definition which has a custom master page and a bunch of customized libraries and lists like task Gantt view, contact bio image views and so on. I can easily add a custom master page in ONET.xml without any issues, but manually setting the custom lists is hard in both aspects of development and debugging. So I started to work on the custom site template which is built by “Save as site template” after setting the lists either in list settings or SharePoint designer. Then I downloaded and imported the sandbox solution file into Visual Studio 2010. I found the solution actually gave us a series of features including lists, view pages, modules, property bags and site template. I also found the features under /Template/Features (See picture 1).

Picture 1

My Solutions

When we open the OOB site definition ONET, I can find site features and web features in the Configuration section (See Picture 2). In Visual Studio sandbox solution, there is also an ONET file used by the site template. In the ONET, there are many features which are generated in custom site template.

Picture 2

Picture 3

I just copy the feature lists section from ONET in site template and replace them in site definition ONET. The new site created by the site definition works well.

Details by Steps

  1. Create a site definition – MYCLIENTSITEDEFINITION which is copied from STS.
  2. Create a site using this site definition and customize lists and library of this site.
  3. Save as site template in site settings page, and save this template as myclient.wsp.
  4. In Visual Studio 2010, create a new project by importing the myclient.wsp and deploy it as a farm solution without DLL by updating solution properties.
  5. Copy <SiteFeatures></SiteFeatures> and <WebFeatures></WebFeatures> from site template solution ONET to site definition ONET and save it.

    (Please remove the lists from site definition configuration. Otherwise, the new lists will conflict with the defined lists.) (See picture 4.)

    Picture 4
  6. Create a new site with the upgraded site definition. The new site will keep all the changes expected that we made in the custom site template.


So far, I could not find many solutions to generate a custom site definition with custom lists. I published this solution (I spent a lot of time to figure out this solution.) in order to hear your opinions or experiences. Also, I'd like to hear your solutions on how to generate a custom site definition easily.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralCan't Read Screenshots Pin
AspDotNetDev8-Jun-11 13:51
mvpAspDotNetDev8-Jun-11 13:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171114.1 | Last Updated 8 Jun 2011
Article Copyright 2011 by DavidMengc
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid