pnp / PnP-Sites-Core

Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Other
415 stars 642 forks source link

Get-PnPProvisioningTemplate and Apply-PnPProvisioningTemplate not applying banner/banner image #1836

Open pjwise opened 6 years ago

pjwise commented 6 years ago

Category

[x] Bug [ ] Enhancement

Environment

[x] Office 365 / SharePoint Online [ ] SharePoint 2016 [ ] SharePoint 2013

Expected or Desired Behavior

1) Create a template from a site with a single page with a banner 2) Provision another site based on this template 3) The provisioned site contains the original page with a banner

Observed Behavior

Banner is not visible on provisioned sites

Steps to Reproduce

1) Create a modern site 2) Create another site page on this site. Add some text and an image to the banner. Set this page as the homepage 3) Create a template from the site (Get-PnPProvisioningTemplate) 4) Create another site of the same type (New-PnPSite) 5) Apply the template to this site (Apply-PnPProvisioningTemplate) 6) Observe that the home page of the new site contains all content from the original site with the exception of the banner template.zip

pdemro commented 6 years ago

What version of PnP Core are you using

jansenbe commented 6 years ago

Please try with June 2018 release as we've had some fixes in this area.

pjwise commented 6 years ago

@jansenbe When I created this I was running 2.26.1805.1. I updated to 2.27.1806.1 and retried. During the provisioning process it fails when applying the pnp:Header with the error "Server relative urls must start with SPWeb.ServerRelativeUrl". The ServerRelativeImageUrl under this header tag is a valid server relative url, however it points to the image on the original site from which the template was created (naturally). This would appear to be the last step in the provisioning process because all expected content is on the new page with the exception of the banner. I can work around this by manually setting the LayoutType of the new page to Article, but it would be very nice if the provisioning engine would recreate the page from the template verbatim.

I appreciate your quick answer and apologize for my delayed response. Let me know if having the updated template file would be of any help.

jansenbe commented 6 years ago

Hi @pjwise ,

I've reproed this issue and fixed it. The root cause was with template extraction: when we extracted a template the image header url was not tokenized and as such we tried to load a file from the "wrong" web resulting in this error. If you want you can already try with our dev release or else wait for the July version which we'll release before next week Tuesday.

pjwise commented 6 years ago

Thanks @jansenbe , I'll give it a test when the July version is released.

pjwise commented 6 years ago

@jansenbe I did another round of testing with the July release and found that the banner is still not copied over to the provisioned site.

With the June release I could get around this issue by:

  1. Setting the LayoutType of the page to Article to make the banner visible
  2. Manually add the banner image in.

With the July release changing the LayoutType does not force the banner to appear. Additionally, it no longer copies the contents of the site assets folder over so the original image isn't present on the provisioned site to be selected if the banner did appear.

Are you familiar with any workarounds for forcing the banner to appear? Essentially I have a client with some template sites containing one page with many webparts. They would like to be able to provision new sites based on these templates when the need arises and a critical part of the page layout is having these banners.

Any advice is appreciated.

The reproduction steps from my original post are still applicable.

jansenbe commented 6 years ago

Does the banner image you've set live in the same site as the page? Can you share the provisioning XML you got when you extracted the site again with the July release?

pjwise commented 6 years ago

@jansenbe It does. It is under 'Site Assets/SitePages/Test-Banner/18322-banner.png', which is where it saved automatically when I uploaded the banner image. On the new site the Site Assets folder is empty.

July_Banner_Test.zip

jansenbe commented 6 years ago

You also need to include the site assets in your template... Are they in?

Get Outlook for Androidhttps://aka.ms/ghei36


From: Pj Wise notifications@github.com Sent: Friday, July 13, 2018 8:07:11 PM To: SharePoint/PnP-Sites-Core Cc: Bert Jansen; Mention Subject: Re: [SharePoint/PnP-Sites-Core] Get-PnPProvisioningTemplate and Apply-PnPProvisioningTemplate not applying banner/banner image (#1836)

@jansenbehttps://github.com/jansenbe It does. It is under 'Site Assets/SitePages/Test-Banner/18322-banner.png', which is where it saved automatically when I uploaded the banner image. On the new site the Site Assets folder is empty.

July_Banner_Test.ziphttps://github.com/SharePoint/PnP-Sites-Core/files/2193701/July_Banner_Test.zip

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/SharePoint/PnP-Sites-Core/issues/1836#issuecomment-404910330, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHGyU69mHBjQsz2mVQZEAOgS0LeqFGZIks5uGOHPgaJpZM4U4W-t.

pjwise commented 6 years ago

@jansenbe In previous versions the template produced by the standard Get-PnPProvisioningTemplate command copied the site assets folder by default. Now it does not appear to do that. Am I now supposed to use a cmdlet option to force it to do that?

jansenbe commented 6 years ago

The extraction will try to find depending assets and add those in, but it will only do that if the PersistBrandingFiles option is turned on in the ProvisioningTemplateCreationInformation. Can you cross check that?

prawnz commented 6 years ago

Tried this on 3.0.1808.1 and have the same error. Took the whole banner tag out and it ran smooth. My situation was a little different where the ServerRelativeImageUrl for the header is pointing to a different site collection and it seems like the code is checking to see whether there is an existing image on the current site collection as indicated via SPWeb.ServerRelativeUrl @jansenbe Can you confirm this?

spkimc commented 6 years ago

I have version 3.0.1808.1 and have the same error but it doesn't seem to happen with extractions made with version 2.28.1807.0. The difference is that {site} is in the XML file when it works and the old path is in the XML file when it is broken.