PnP Provisioning of SP Apps or multiple files/directories

Highlighted
Occasional Visitor

Hi there all,

 

I'm fairly new to pnp so i have a lot to cover. Not in this discussion - but in general. I am very excited by it. This question is about pnp provisioning template.

 

I just wanted to put this question out there/here for anyone else that may have been trying this out.

 

I'm currently finding that for provisioning stuff like content types, columns, lists etc works great every time using the pnp provisioning engine. My next step is to provision my App files (i have not moved to the Add-in model yet - so im not sure if provisioning multiple app files is covered there).

I have been trying to use <pnp:directory ....> to deploy multiple files, but everything i am trying i am getting the same error.

 

System.ArgumentException: 'fileName'

 

so i have tried:

<pnp:Directory src=".\StyleLibrary\Apps" Folder="Style%20Library" Overwrite="true" />

...and

<pnp:Directory src=".\StyleLibrary\Apps" Folder="Style%20Library" Overwrite="true" />

...and

<pnp:Directory src="c:/bla/StyleLibrary/Apps" Folder="Style%20Library" Overwrite="true" />

 

My only thought is that i now need to use:

<pnp:File src=".\StyleLibrary\logo.png" Folder="{site}/Style%20Library/img/" Overwrite="true" />

for every single file.

 

This i find a little non-productive.

 

For example: I wrote a powershell script that extracted files from SharePoint directory and then upload all files, including files in sub folders, to a directory in Sharepoint. And this works well. But I would like to do this with PnP provisioning engine as then it will be a complete package for my apps.

 

So my question is, or my requested guidance is around multiple file uploads with the pnp provisioning engine and if anyone has been successful - or am i completely missed the point and should be focusing on another method.

 

Any thoughts or pointers would be excellent.

 

thanks in advance.

Shaun

 

1 Reply
Highlighted

Hi,

This Directory node is working fine for me:

 

        <pnp:Directory
          Src=".\MyLocalStyleLibrary\images"
          Folder="{site}/Style Library/MyProject/images"
          Overwrite="true" Level="Published"></pnp:Directory>
 
The only difference is that I'm using the {site} token in the Folder.
 
Also, How are you applying the template? using PnP PowerShell command? or with custom C# code calling PnPCore library?