Sharepoint 使用Office开发PnP在子网站上应用提供模板

Sharepoint 使用Office开发PnP在子网站上应用提供模板,sharepoint,office365,officedev,Sharepoint,Office365,Officedev,我想在一项本应是“公园散步”的任务上得到一些帮助,但最终给我带来了不少麻烦。 情况简介: 客户有一个专门的网站集用于其网站创建,即“/sites/customersite”。 在此网站下,将创建一个子网站,以放置所有不同的可用模板“/sites/customersite/templates”。 目前,用户可以基于固定模板“/sites/customersite/templates/templateweb1”创建web。 网站将以“sites/customersite/{yyyy}/{MM}/HH

我想在一项本应是“公园散步”的任务上得到一些帮助,但最终给我带来了不少麻烦。 情况简介:

客户有一个专门的网站集用于其网站创建,即“/sites/customersite”。 在此网站下,将创建一个子网站,以放置所有不同的可用模板“/sites/customersite/templates”。 目前,用户可以基于固定模板“/sites/customersite/templates/templateweb1”创建web。 网站将以“sites/customersite/{yyyy}/{MM}/HHmmss”格式在网站下创建

考虑以下从控制台应用程序运行的代码:

// 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);
我希望没有问题,因为这是一个干净的团队站点,只应用了一个站点图标和spcolor文件。 但是在“ObjectFiles”中我得到了一个很好的例外。。 在每次检查文件时,文件夹具有以下值“{themecatalog}/15”,目前为止效果良好。 然后文件夹名是“/sites/customersite/\u catalogs/theme/15”。 但是,当实际文件夹被提取时,“ServerRelativeUrl”包含以下值“/sites/customersite/2015/10/161446/sites/customersite/_catalogs/theme/15” 当然给休错误


因此,如果有人能告诉我我遗漏了什么,我将非常感激。

在您提供的代码示例中,我没有看到for each循环。还有更多的代码可以共享吗?目标web已经用我描述的逻辑创建了。提供的代码用于获取模板web,连接文件连接器,然后尝试将模板应用到目标web。这里每个循环都不需要。应用是在创建之后直接完成的。在您提供的代码示例中,我没有看到for-each循环。还有更多的代码可以共享吗?目标web已经用我描述的逻辑创建了。提供的代码用于获取模板web,连接文件连接器,然后尝试将模板应用到目标web。这里每个循环都不需要。应用是在创建之后直接完成的。