1

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.

Mathieu
  • 367
  • 3
  • 11
  • I don't see a for each loop in the code sample you provided. Is there more code you can share? – Thriggle Oct 23 '15 at 19:09
  • The target web was already created with the logic that I described. The code is provided to fetch the template web, connect the file connector and then trying to apply the template to the target web. No for each loop is needed here. The apply is done directly after the creation. – Mathieu Oct 26 '15 at 08:40

0 Answers0