Upgrade gotcha – Microsoft don’t follow it’s own recommendations for web template ID’s!

During a recent upgrade of a SharePoint 2010 solution to 2013 I discovered something I first thought must be a bug in the upgrade process.

It was actually just “luck” that made us aware of the problem. Under each region site we had a landing page where users could add sub webs using a custom web part for provisioning. Visually you couldn’t tell something was wrong, but the provisioning failed because the custom code in the web part required the landing page to be of a specific site definition.

Sure enough, the WebTemplate property of the web revealed that the template is DOCMARKETPLACESITE. At first I thought I had made an error in the XML file that you place in 15\CONFIG\UPGRADE before upgrade. But no, it looked OK. And there was no signs of what had happened in the upgrade logs – except for a successfully web upgrade.

Then it hit me, what site definition id do DOCMARKETPLACESITE use? Oh, “10000” – the same as ours!

But hey, isn’t that a “reserved” ID for custom site definitions according to the documentation:

Specifies the ID of the site definition. To avoid conflict with IDs that are natively used in Microsoft SharePoint Foundation, use IDs with values greater than 10,000 when you create custom site definitions.

You can argue that they say greater than 10.000, but I bet most people don’t expect Microsoft to use 10.000…

To solve this we had to do the following:

  1. Change the web template ID in the SP2013-version of the site definition to a new number (15/TEMPLATE/<lcid>/XML/webtemp*.xml)
  2. Create a web on the same level as the old one, but using the new template
  3. Move all subwebs to the new web (Export-SPWeb / Import-SPWeb)
  4. Delete the old web
  5. Rename the new web

A basic check that could have revealed this earlier is to run the following PowerShell script in old and new environment and do a text compare to spot changes:

$wa = Get-SPWebApplication <URL> 
$wa | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select-Object Url, WebTemplate | Export-Csv ".\[NAME].csv"

Thank God for Windows Home Server!

This week was the first in my new job in Bouvet ASA in Oslo. On the first day I was handed a Lenovo ThinkPad W500 with Windows 7. I installed SharePoint 2007, Visual Studio 2008 and all the dozens of applications and utilities I can’t develop without. After a couple of days I was told it was very likely I would start on a SharePoint 2010 project. Cool! Since the machine only had 4 GB of RAM it was out of the question to run SharePoint 2010 in a virtual machine. I decided to make a VHD with Windows Server 2008 R2, SharePoint 2010 and Visual Studio 2010 and boot from it. At the end of the week I had two complete and separate development environments for both SharePoint versions on my machine. I had even started to prepare for the potential 2010 project by making a test project to investigate some ideas I had.

On Saturday I booted into Windows 7 and read news as usual while eating breakfast. After that I rebooted into Windows 2008 R2 and wanted to work some on my test-project. After the boot load screen I got an bluescreen. Booted into Safe Mode, but again got an bluescreen. Tried to boot into Windows 7 but that bluescreened as well! WTF happened?!?

I would normally boot with a bootable utility CD to be able to fix problem or rescue files, but I thought this was an excellent opportunity to test a restore from my Windows Home Server backup.Luckily I had installed the WHS client on the Windows 7 machine and a full backup, including the VHD, was done Friday night. After 30 minutes downloading and burning the Restore CD and put network drivers on a USB stick – and then 1,5 hour restore time my machine was in perfect state.

Thank God for Windows Home Server!