Open Pieter-Veenstra opened 6 years ago
How about using the PersistBrandingFiles
parameter.
In PS, it would be :
Connect-PnPOnline -Url $sourceUrl -CreateDrive -Credentials $credentials
md ‘c:\Scripts\site1’ -ErrorAction Ignore
cd ‘c:\Scripts\site1’
Get-PnPProvisioningTemplate -Out 'site1Template.xml' -PersistBrandingFiles -FORCE -Verbose -Debug
I have tried it using CSOM and its saving the composed look, the code I am using is:
ProvisioningTemplateCreationInformation ptci
= new ProvisioningTemplateCreationInformation(ctx.Web);
// Create FileSystemConnector to store a temporary copy of the template
ptci.FileConnector = new FileSystemConnector(@"c:\temp\pnpprovisioningdemo", "");
ptci.PersistBrandingFiles = true;
ptci.ProgressDelegate = delegate (String message, Int32 progress, Int32 total)
{
// Only to output progress for console UI
Console.WriteLine("{0:00}/{1:00} - {2}", progress, total, message);
};
// Execute actual extraction of the template
ProvisioningTemplate template = ctx.Web.GetProvisioningTemplate(ptci);
// We can serialize this template to save and reuse it
// Optional step
XMLTemplateProvider provider =
new XMLFileSystemTemplateProvider(@"c:\temp\pnpprovisioningdemo", "");
provider.SaveAs(template, "PnPProvisioningDemo2.xml");
Hi @gautamdsheth ,
I am using the -PersistBrandingFiles in my Get-PnPProvisioningTemplate
I've got the feeling that this is simply a bug as SP2016 seems to handle Composed looks very differently. When I stepped through the code I was actually shocked at how many workarounds on workarounds there are. It looks like when the code was written the Composed looks setup either changed a couple of times and then the code tried to handle all situations or the code is simply a mess.
I don't really dare changing the code as there must have been a reason for this.
Just a quick example of one of the issues:
All the configured composed looks are read from the composed looks list. Then we step multiple times through all the items. Find the Current composed look. Then using the url of the composed look file the actual composed look is found.
The better way in my opinion would be query the Composed Look list for the Current Composed look. ( returning just one item!) Then query the list again with the Compose look URL.
I'm guessing that one of the complexities is that by default the Current composed look is not set until a non-default composed look is set.
Category
[X] Bug [ ] Enhancement
Environment
[X] Office 365 / SharePoint Online [X] SharePoint 2016 [ ] SharePoint 2013
If SharePoint on-premises, what's exact CU version:
Expected or Desired Behavior
When exporting a template from one site to another the composed look should be picked up.
Observed Behavior
I've found that this doesn't happen and the composed look is ignored
Steps to Reproduce
See here:
https://techcommunity.microsoft.com/t5/SharePoint-Developer/PnP-templates-lose-colours/m-p/145411#M4138
Workaround
Create custom composed looks: https://veenstra.me.uk/2018/01/16/office-365-sharepoint-online-vs-sharepoint-2016-composed-looks/