in

Dot Net Mafia

Group site for developer blogs dealing with (usually) Ionic, .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for Ionic, SharePoint, and Office 365.

How to: Create a Site Definition using Visual Studio 11

I’ve posted a number of articles about Visual Studio 11 to date and today’s article talks about the new SharePoint Project Item, Site Definition.  This is a new SPI available in Visual Studio 11.  Previously, you had to create site definitions manually or using the Community Kit for SharePoint.  This new template has enough to get you started.  Start off by creating a new blank SharePoint project and then add a new item.

VS11SPISiteDefinition

Notice how the Add New Item dialog indicates that Site Definitions are available in Farm Solutions only.  Once you create the new item, you’ll have three items created for you visible in the Solution Explorer, a default.aspx, onet.xml, and a webtemp_<sitedefinition>.xml.

VS11SiteDefinitionSolutionExplorer

I won’t go into the details of the specific of what goes into each specific file, since there are many posts out there already covering that.  However, I will show you what each file looks like.  We’ll start with onet.xml.

VS11SiteDefinitionOnetXml

Onet.xml controls the features that the site definition automatically activates as well as custom list instances.  The files support IntelliSense so that will help you customize the XML as you can see in this example below.

VS11SiteDefinitionOnetXmlFeature

The WebTemp XML file automatically has the name of the site definition appended to it.  You can customize this file with multiple configurations as well as change the category.  In the example below, notice that the DisplayCategory is set to SharePoint Customization.  If you are deploying multiple site definitions be sure and change the ID to avoid conflicts.

VS11SPISiteDefinitionWebTemp

The default.aspx file contains a simple placeholder that gets you started.  Of course, you will likely want to create custom WebPartZones to allow someone to add web parts to your page.

VS11SiteDefinitionDefaultAspx

Once you have made any customizations that you would like, deploy your solution.  One thing to remember when deploying site definitions is that an iisreset is required.  When I deployed my solution the first time, it did not show up in the New Site list.  I deployed the solution again and I could pick it from the list.

VS11SiteDefinitionDeployed

Notice that it’s in the SharePoint Custom category.  Create your new site and when it is complete, you should have a site definition that looks like the one below.

VS11SiteDefinitionPage

That’s what you get.  It’s nothing fancy but it might save you a few steps the next time you have to deploy a site definition.

Comments

 

Windows 8 Developer Links – 2012-05-31 | Dan Rigby said:

Pingback from  Windows 8 Developer Links &#8211; 2012-05-31 | Dan Rigby

May 30, 2012 11:11 PM
 

SharePoint Daily » Blog Archive » You Don’t Want SharePoint; Office 365 for US Government Released; Windows 8 Preview Ships Today said:

Pingback from  SharePoint Daily  &raquo; Blog Archive   &raquo; You Don&#8217;t Want SharePoint; Office 365 for US Government Released; Windows 8 Preview Ships Today

May 31, 2012 7:37 AM
 

SharePoint Daily said:

Installing Windows 8 means no class action suits against Microsoft . - Dooley Top News Stories The Art

May 31, 2012 7:44 AM
 

You Don’t Want SharePoint; Office 365 for US Government Released; Windows 8 Preview Ships Today – Bamboo Solutions said:

Pingback from  You Don&#8217;t Want SharePoint; Office 365 for US Government Released; Windows 8 Preview Ships Today &#8211; Bamboo Solutions

June 6, 2016 2:56 AM
 

You Don’t Want SharePoint; Office 365 for US Government Released; Windows 8 Preview Ships Today – Bamboo Solutions said:

Pingback from  You Don&#8217;t Want SharePoint; Office 365 for US Government Released; Windows 8 Preview Ships Today &#8211; Bamboo Solutions

June 7, 2016 10:15 PM

Leave a Comment

(required)  
(optional)
(required)  
Add

About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2018 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems