Feb 05 2017 03:08 PM - edited Feb 05 2017 03:35 PM
Todays issue
Hi am using the latest Powershell extension and each tilme i run Appl-PnPProvioningTemplate i get the error Apply-PnPProvisioningTemplate : Cannot access a closed Stream. At line:1 char:1 + Apply-PnPProvision. I enabled logging and i dont see anything that could hint the cause of the error. Same thing happen if I use c# code
Feb 05 2017 09:29 PM
Feb 05 2017 10:34 PM
please post the xml so we can look at what is happening.
Feb 05 2017 11:17 PM
This error message typically indicates a Checked-out file. There's probably a pnp:File definition in your template for a File that's checked out. Could this be your issue?
Feb 06 2017 03:06 AM
See also this issue I reported a few months ago
https://github.com/SharePoint/PnP-Sites-Core/issues/796
Feb 06 2017 06:16 AM
Followed instruction her and i found one file that was checked out. However i still get the error after checking it in. Each time i try to upload the .pnp file i am geting the error "THe contents of the attachment doesnt match its file type"
Feb 07 2017 04:19 AM
Also please see the template I am trying to apply downloadable from the link below:
https://drive.google.com/file/d/0BwBQnwZDg9M6M09KS0F1REE0MU0/view?usp=sharing
Feb 07 2017 05:25 AM
just a guess but where is the proviosing template? it is in a zip? as far as i know you can not use a zip to apply template.
maybe i am wrong here but if you do a get template you get xml which you can provision back..
Feb 07 2017 06:24 AM - edited Feb 07 2017 06:30 AM
Since june 2016 release of PnP you can extract templates to a file with a .pnp extension which is effectively a ZIP file containing all provisioning artifacts
Feb 08 2017 09:52 AM
still having this issue. I am not sure if i mentioned that this is a publishinfg site. If the error is because of a checked out file how can i know what file is being checked out. I created over the site and every site assets i added i ensured that it was published and check in
Feb 08 2017 10:18 AM
If I understand you got a different error after you checked in the file. Before the file was checked in you got "Cannot access a closed stream". After checking in you got "THe contents of the attachment doesnt match its file type".
I'm not familiar with that last error message. When exactly do you get this message? Are you working against a SharePoint Online environment or on-premises? I
Feb 08 2017 10:24 AM
Feb 08 2017 10:34 AM
Feb 08 2017 10:37 AM
Is this something I have to do manually or this
Get-PnPProvisioningTemplate -PersistBrandingFiles
do all of that for me. If its manul can you point me in the right direction.
Thanks again guys for all your help
Feb 08 2017 11:18 AM
Feb 09 2017 04:18 AM
In order to replicate the issue try the following
1. Create two site collection using the publishing template one will be used to apply your custom branding and the other is the one you will use powershell to apply said branding
2. Create a simple html file and call it whatever you want. in my case I called it simple.html
my file only had this
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
3. Use design manger to upload this template to the Master Page Gallery of the site collection you want to apply branding to.
4. Go to Edit Master Pages in Design Manager and then click Convert an HTML file to a SharePoint master page.
5. Select the html file you uploaded earlier and this will convert your file to master page file.
6. In design manager gor to Publish and Apply design the click on go o the master page gallery.
7. Go to were you had uploded you html file and you will see the .master file. Ensure all files are published and checked in.
8. Go to site Settings and click on Master page. In the drop downbox select your newly created master page. This will apply you custom branding.
Basically i followed the steps here using the simpliest of html file with no site assets "http://www.sharepointempower.com/Blog/Post/3/SharePoint-2013-branding-step-by-step"
The next steps are to now get the provisioning template using powershell from your branded site the use powershell to apply the branding to you other site collection (make sure it was created using publishing template)
I used the following parameters when I was getting the publishing template -PesistBrandingFiles -PersistPublishing Files. I find that if i dont use PersistPublishingFiles it doesnt provision my html file.
As far you can see what i am doing is basic and its not working
Feb 09 2017 05:48 AM
SolutionI've followed the steps you took and I got the same error as you got. The file causing the error was simple.master. During Provisioning PnP is trying to overwrite the file while it is checked out during conversion of the simple.html file to a master page.
I was able to fix the error and get the desired results following the steps below:
I consider this a bug in PnP and I'd suggest you to submit an issue in PnP describing your steps to reproduce and my steps to work around this.
Hope this helps!
Feb 09 2017 08:21 AM
For anyone who stumble up on this error please follow up on the issue report here:
Feb 09 2017 05:48 AM
SolutionI've followed the steps you took and I got the same error as you got. The file causing the error was simple.master. During Provisioning PnP is trying to overwrite the file while it is checked out during conversion of the simple.html file to a master page.
I was able to fix the error and get the desired results following the steps below:
I consider this a bug in PnP and I'd suggest you to submit an issue in PnP describing your steps to reproduce and my steps to work around this.
Hope this helps!