如何使用PnP配置引擎在SharePoint Online中设置发布页面?

时间:2016-03-02 10:14:35

标签: sharepoint office365 csom sharepoint-online

我正在使用PnP Provisioning Engine将一个网站集远程配置到SharePoint Online中的另一个网站集,如此视频所示:https://channel9.msdn.com/blogs/OfficeDevPnP/Introduction-to-PnP-site-remote-provisioning-engine

它适用于其余的东西,但它没有配置发布页面。我创建配置模板的代码如下:

private static void GetProvisioningTemplate(ConsoleColor defaultForeground, string webUrl, string userName, SecureString password)
{
    using (var context = new ClientContext(webUrl))
    {
        context.Credentials = new SharePointOnlineCredentials(userName, password);
        Web web = context.Web;
        context.Load(web, w => w.Title);
        context.ExecuteQueryRetry();

        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("Your Site Title is: " + context.Web.Title);
        Console.ForegroundColor = defaultForeground;

        ProvisioningTemplateCreationInformation ptci = new ProvisioningTemplateCreationInformation(web);

        ptci.FileConnector = new FileSystemConnector(String.Format(@"{0}\..\..\", AppDomain.CurrentDomain.BaseDirectory), "");

        ptci.PersistBrandingFiles = true;
        ptci.PersistPublishingFiles = true;
        ptci.IncludeNativePublishingFiles = true;

        ptci.ProgressDelegate = delegate(String message, Int32 progress, Int32 total)
        {
            Console.WriteLine("{0:00}/{1:00} - {2}", progress, total, message);
        };

        ProvisioningTemplate template = web.GetProvisioningTemplate(ptci);

        XMLTemplateProvider provider = new XMLFileSystemTemplateProvider(String.Format(@"{0}\..\..\", AppDomain.CurrentDomain.BaseDirectory), "");
        provider.SaveAs(template, "PnPProvisioningDemo.xml");
    }
}

当我检查XML模板时,它没有向我显示发布页面的详细信息,也没有在应用此模板时将任何发布页面配置到目标站点。

所以建议使用此引擎配置发布页面。

提前致谢。

1 个答案:

答案 0 :(得分:2)

我已经读过配置引擎不支持发布页面。

来源:https://techcommunity.microsoft.com/t5/SharePoint-Developer/PnP-Provisioning-Engine-template-support-for-publishing-pages/td-p/46465来自02-16-2017。

但您可以使用pnp:File

添加发布页面
<pnp:File src="mypublishingpage.aspx" Folder="{site}/Pages" Overwrite="true">
    <pnp:Properties>
        <pnp:Property Key="ContentTypeId" Value="{contenttypeid:MyPageContentType}" />
        <pnp:Property Key="Title" Value="My Publishing Page" />
        <pnp:Property Key="PublishingPageLayout" Value="{sitecollection}/_catalogs/masterpage/MyPageLayout.aspx,  My Page Layout" />            
    </pnp:Properties>
</pnp:File>
相关问题