https://github.com/OfficeDev/PnP-Sites-Core/issues/204
Similar issue here, I left a comment, was unsure if it would be seen as it was closed.
Apply-SPOProvisioningTemplate -Path C:\TempXML\template.xml -Web $web -ResourceFolder C:\TempXML
Apply-SPOProvisioningTemplate : Value cannot be null.
Parameter name: stream
At line:5 char:1
I have run into this a lot. It is almost always caused (at least for me) when a
hmmm, ok ill checkout the XML, I'd used the Get-SPOProvisioningTemplate so unsure why its having a problem. All files have been placed in the folder location
If you setup the logging (it is easy to do in C#, not sure about PoSh though) it is really easy to figure out which file is the offender.
Ok great, whats involved with regards to setting up the logging, I had got a similar issue when using code in C# as well as PowerShell.
I have just tried 2 new site collections, Template and Target using PS, no failures this time although it didn't copy over the background image within the theme.
Not sure about PoSh but in C# just add something like this your config file.
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="logListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="MyLogFile.log" />
</listeners>
</trace>
</system.diagnostics>
great thanks ill give that a go :+1:
@SimonPurr did you find a resolution? I'm seeing the same error.
Can please anyone give a solution for this problem? I have the same error and don't have a solution for this. Thank in advnace.
I also have the same error. Seems like Get-SPOProvisioningTemplate is really buggy. . .
to turn on logging for the Apply-PnPProvisioningTemplate use
Set-PnPTraceLog -On -LogFile C:\pathtoyourlogfile.txt -Level Debug
The error message as described above is most likely indeed to a specific file the engine tries to find, but fails to find. It's a cryptic message unfortunately which is thrown by the CSOM api. If you do Get-PnPProvisioningTemplate you have to explicitely state that you also want to persist the files, otherwise the template only contains references to the files, but the actual files will be assumed already to be present on the server.
Get-PnPProvisioningTemplate -Out yourfile.xml -PersistBrandingFiles -PersistPublishingFiles
(the last parameter only has effect on a publishing site).
What i must do for solving this issue is the following:
in the XML file that is generated for the
My file structure is the following one:
Template
-> pnptemplate.xml
-> Paginas
-> Landingspagina.aspx
Hopefully this is helping.
This is the same as #414
Is there any way I can read locally stored .pnp templates and apply it to site in C#
In that way, I can also apply files which are stored on local file system.
???
Please help.
Use the .xml format instead of .pnp
I am using the pnp partner pack and it uses .pnp format
Still, I have branding files like master, images which I want to apply to new site as well
Hi team,
It worked with using OpenXMLConnector and with the help of below ref. links
https://dev.office.com/blogs/sharepoint-pnp-remote-provisioning-engine-august-2016
Ok, considering that #414 (same issue explained here) has been fixed and closed and considering that the other issue mentioned here has been fixed, I will close this item. Thanks for your feedbacks.
internal test results
Source:
<pnp:File Src="Pages\default.aspx" Folder="{site}/Pages" Overwrite="true" Level="Published">
<pnp:File Src="_catalogs\masterpage\VariationRootPageLayout.aspx" Folder="{masterpagecatalog}" Overwrite="true" Level="Published">
Success:
@jansenbe : Did you do that with the january release? Or which version do you use?
January release
Hi,
I also have this same issue. The site does not use publishing, and there are no file artifacts included, except what is provisioned with the STS#0 template.
I have tried using the various -persist* switches, but the apply-pnptemplate always fails with the following error message:
writeErrorStream : True
PSMessageDetails :
Exception : System.ArgumentNullException: Value cannot be null.
Parameter name: source
at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)
at OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLPnPSchemaV201605Formatter.ToProvisioningTemplate(Stream template, String identifier)
at OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLPnPSchemaFormatter.ToProvisioningTemplate(Stream template, String identifier)
at OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLTemplateProvider.GetTemplate(String uri, String identifier, ITemplateFormatter formatter, ITemplateProviderExtension[] extensions)
at OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLTemplateProvider.GetTemplate(String uri, ITemplateProviderExtension[] extensions)
at SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate.ExecuteCmdlet()
at SharePointPnP.PowerShell.Commands.SPOCmdlet.ProcessRecord()
TargetObject :
CategoryInfo : WriteError: (:) [Apply-PnPProvisioningTemplate], ArgumentNullException
FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}
I am using powershell, pnp version:
SharePointPnPPowerShellOnline 2.11.1701.1
Available in S4B / TeamViewer if necessary.
@kmosti : can you share your template? Will re-open the issue in the meanwhile
I think I figured it out.
I had left the top navigation menu blank (removed the "Home" default node), once I added this back in everything seems to be in order.
Can we perhaps add a check to this?
I seem to run into the same problem.
SharePoint 2016
latest pnp version
Host Named SiteCollection !!?
standard, default publishing site, nothing added.
Get-PnPProvisioningTemplate -Out abc.xml (no SwitchParameters used)
Thanks
Adding "-ExludeHandlers Publishing" (no quotes) to the get command seems to fix that
However no publishing pages are provisioned :(
Right, back where we started from, trying to add a publishing page to a site :(
this is what I add to the template :
This is what I get (powershell) :
Apply-PnPProvisioningTemplate : Value cannot be null.
Parameter name: stream
At line:1 char:1
I've tried all combinations of paths, slashes ....... all to no avail
Ok, Set you welcome page to page2.aspx
Then run:
Get-PnPProvisioningTemplate -Web $web -Out "c:\SP-ProvisioningGateWay\templates\template.xml" -PersistBrandingFiles -PersistPublishingFiles
This will also create a folder with your page (page2.aspx) in it.
Then run
Set-PnPTraceLog -On -Level Debug
Apply-PnPProvisioningTemplate -Web $web -Path "c:\SP-ProvisioningGateWay\templates\template.xml"
Does this work?
The Get .... creates a _Catalog folder (_catalog/masterpages/....)
No other folders
Ok, we can try it manually then. Create a folder SitePages or Pages in the templates folder then add a copy of your page2.aspx file in here and then try the apply again.
This works (after changing the src path to "pages\page2.aspx") thanks
So I need a way to get the aspx files downloaded.
FYI, the template exported by the get... does not contain reference to page2 (except as welcome page)
No 'pnp:File'
Next step will be to add the webparts - I think I might be coming back here :)
Thanks a lot
Only the welcome page is exported. In general I go through all my pages and set them as welcome page and then export each page in its own template file.
Using the get... command not even the welcome page was/is exported (in my case anyway). I had to download the page manually.
Which is do-able in a first iteration, but my client wants a fully automated process at the end.
In my case I also received an error:
Apply-SPOProvisioningTemplate : Value cannot be null.
Parameter name: stream
This issue was caused because the welcome page was not located on the drive location where the script was executed. I received the following error message in my PnP tracelog file:
File HomepageShop.aspx not found in directory SitePages. Exception = Could not find a part of the path 'C:\Scripts\Provisioning\SitePages\WelcomePage.aspx'
Apparently this file needs to be available within the SitePages folder where the script is executed. Whenever I put the welcomepage aspx file there, the script works. Strange enough the WelcomePage from my template is used, and not the downloaded file.
Did you specify the needed flags to download the files?
Sorry to hijack this one but I do think there's a but here. With version 2.15.1705 installed we noticed the following:

Take notice of the absolute path, which is a valid one. Now when trying to provision we get the stream error and when looking into the diagnostics trace log:
[Error] File BZ.SPCOLOR not found in directory D:\src\SiteCreation\BZ.Plaza.SiteCreation.Job\ProvisioningTemplates\SubjectSite\theme. Exception = Could not find a part of the path 'D:\src\SiteCreation\BZ.Plaza.SiteCreation.Job\bin\Debug\src\SiteCreation\BZ.Plaza.SiteCreation.Job\ProvisioningTemplates\SubjectSite\theme\BZ.SPCOLOR'. 0ms
Compare the path it's trying to open with the path specified in the XML; it's not the same. It seems it's treating it as a relative path somehow even though the XML is specifying an absolute path? So there does seem to be something wrong here.
The objectHandler ObjectFiles will always use executing directory as default path and yes, it will combine file src as if it was relative. So, if you run your solution in debug, it will expect files to be in your bin/debug folder.
It took me a while to see that one, it should use absolute paths or at least use provision xml directory, since Get-provision upload files in there.
Yeah that's what I found as well. It's a bug in my opinion, or it should be made very clear in the documentation cause this is counter intuitive.
@jsiegmund We fixed this issue by defining a fileSystemConnector object.
var fileSystemConnector = new FileSystemConnector(configFile.DirectoryName + "\FilesToUpload", "");
template.Connector = fileSystemConnector;
and directly mention the file name in the xml file
Most helpful comment
The objectHandler ObjectFiles will always use executing directory as default path and yes, it will combine file src as if it was relative. So, if you run your solution in debug, it will expect files to be in your bin/debug folder.
It took me a while to see that one, it should use absolute paths or at least use provision xml directory, since Get-provision upload files in there.