Introduction
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.
Background
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
- Create a site definition –
MYCLIENTSITEDEFINITION
which is copied from STS. - Create a site using this site definition and customize lists and library of this site.
- Save as site template in site settings page, and save this template as myclient.wsp.
- 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.
- 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
- 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.
Conclusion
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.