Forum Discussion
David Grooms
Apr 25, 2017Copper Contributor
PnP Provisioning template to automate sites
I'm currently using the XMLTemplateProvider class to load an xml template and apply it to the site. This works fine. The issue is that this interface only takes a file and I'd like to store the mode...
Steve Borgwardt
May 02, 2017Copper Contributor
Have you looked at the code in the PnP Partner Pack for provisioning? They create an Infrastructure site collection and store all the PnP provisioning template XML files in doc libraries.
https://github.com/SharePoint/PnP-Partner-Pack
You can still use the XMLTemplateProvider, but instead of the XMLFileSystemTemplateProvider, use the XMLSharePointTemplateProvider (part of PnP Core) and pass in context, Web URL and ensure the list item has a File property.
Then using the ProvisioningTemplate class to to hold the template from the XML provider using the provider.GetTemplate(item.File.Name) method.
ProvisioningTemplate template = provider.GetTemplate(item.File.Name);
You can look at the source code starting at line 50 - 111
SharePointProvisioningRepository.cs
Thanks