I would like to have some help with a task that should have been "a walk in the park" but in the end gives me quite some troubles. Situation sketch:
The customer has a dedicated site collection for his web creation being "/sites/customersite". Under this site a subsite is created to put all the different available templates "/sites/customersite/templates". A person can create a web, for the moment based on a fixed template "/sites/customersite/templates/templateweb1". The web will be created under the web under the format "sites/customersite/{yyyy}/{MM}/HHmmss"
Consider following code ran from console app:
// Build template from template web
var templateWeb = _context.Site.OpenWeb("/sites/customersite/templates/templateweb1");
_context.Load(templateWeb);
_context.ExecuteQuery();
// Put file connection to files that can not be fetched ex. siteIcon and spcolor file
// Will resolve to path where console is run from taking the CreationResources \bin\Debug\CreationResources
string fileConnection = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CreationResources");
var ptci = new ProvisioningTemplateCreationInformation(templateWeb)
{
PersistComposedLookFiles = true,
FileConnector = new FileSystemConnector(fileConnection, string.Empty)
};
// Get template from live web
var provisioningTemplate = templateWeb.GetProvisioningTemplate(ptci);
provisioningTemplate.Connector = new FileSystemConnector(fileConnection, string.Empty);
targetWeb.ApplyProvisioningTemplate(provisioningTemplate);
I would expect no issue because this is a clean team site, only a site icon and spcolor file applied. But in the "ObjectFiles" I get a nice exception.. In the foreach going over the files the file folder has following value "{themecatalog}/15", so far so good. Then the folderName is "/sites/customersite/_catalogs/theme/15". But then when the actual folder is fetched the "ServerRelativeUrl" contains the following value "/sites/customersite/2015/10/161446/sites/customersite/_catalogs/theme/15" Giving of course hugh errors.
So if somebody can enlighten me on what I am missing, I would very much appreciate it.