'How to provision Publishing Pages in SharePoint Online using PnP Provisioning Engine?
I am using PnP Provisioning Engine for remote provisioning of one site collection to another site collection in SharePoint Online as shown in this video: https://channel9.msdn.com/blogs/OfficeDevPnP/Introduction-to-PnP-site-remote-provisioning-engine
It works fine for rest of the things but it is not provisioning publishing pages. My Code to Create a provisioning template is as below:
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");
}
}
When I checked XML template it's not showing me details of Publishing pages and also not provisioning any publishing pages into target site while applying this template.
So any suggestion to provision publishing pages using this engine.
Thanks in advance.!
Solution 1:[1]
I have read that publishing pages are not supported in the provisioning engine.
Source: https://techcommunity.microsoft.com/t5/SharePoint-Developer/PnP-Provisioning-Engine-template-support-for-publishing-pages/td-p/46465 from 02-16-2017.
But you can add publishing pages with 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>
Solution 2:[2]
try
ptci.IncludeAllClientSidePages = true;
Assembly PnP.Framework, Version=1.9.0.0
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Axel |
Solution 2 | Suraj Rao |