SharePoint – Site Definition failed to deploy

There are many articles about site definitions. The trend seems to go towards using less site definitions or at least smaller site definitions and adding features to do all the work. Having said that, I still like to use site definitions for an initial deployment (read deployments before the customer has gone into production) as it’s easy to make small changes the main structure of the site and redeploy the solution.

Many things can fail however and today I came around yet another silly problem (they’re always silly typo mistakes and many silly mistakes create one difficult puzzle) and my site definition failed to deploy.

I got these exception messages in my ULS logs after I created a site collection using my new template:

CreatePortal failed creating portal webs. Microsoft.SharePoint.SPException: The template you have chosen is invalid or cannot be found. —> System.Runtime.InteropServices.COMException (0x81071E44): The template you have chosen is invalid or cannot be found.
at Microsoft.SharePoint.Library.SPRequestInternalClass.ApplyWebTemplate(String bstrUrl, String bstrWebTemplateContent, Int32 fWebTemplateContentFromSubweb, Int32 fDeleteGlobalListsWithWebTemplateContent, String& bstrWebTemplate, Int32& plWebTemplateId)
at Microsoft.SharePoint.Library.SPRequest.ApplyWebTemplate(String bstrUrl, String bstrWebTemplateContent, Int32 fWebTemplateContentFromSubweb, Int32 fDeleteGlobalListsWithWebTemplateContent, String& bstrWebTemplate, Int32& plWebTemplateId) –
— End of inner exception stack trace —
at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
at Microsoft.SharePoint.Library.SPRequest.ApplyWebTemplate(String bstrUrl, String bstrWebTemplateContent, Int32 fWebTemplateContentFromSubweb, Int32 fDeleteGlobalListsWithWebTemplateContent, String& bstrWebTemplate, Int32& plWebTemplateId)
at Microsoft.SharePoint.SPWeb.ApplyWebTemplate(String strWebTemplate)

In these caes you know that there is something wrong somewhere. So I checked that my template name was consistent throughout the solution.

All looked ok.

Then I checked my webtemp and noticed the ID beign set to 0

<Template Name=”MyWeb” ID=”0″>

I changed the ID to 10001:

and all worked fine.


Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Avatar of Pieter Veenstra

Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There's a better way — and I can show you exactly what it looks like. I'm the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide. For over 30 years I've been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions. SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/ Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/ You can contact me using contact@sharepains.com

Related Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains

Subscribe now to keep reading and get access to the full archive.

Continue reading