pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
985 stars 665 forks source link

[BUG] Add-PnPListFoldersToProvisioningTemplate - does not update .pnp file #2933

Open stukkendfc opened 3 years ago

stukkendfc commented 3 years ago

Reporting an Issue or Missing Feature

Add-PnPListFoldersToProvisioningTemplate does not update a .pnp file with the folders in the selected library.

Expected behavior

To update the given Provisioning Template with the folders in the given library.

Actual behavior

Template file is not updated with the folders when the Template file is of type .pnp (e.g. Filename.pnp). Command does add the folder structure if the Template file is of type .xml (e.g. Filename.xml).

When applying the template using .pnp file, no folders are added to the library.

Steps to reproduce behavior

Add-PnPListFoldersToProvisioningTemplate -Path "c:\Templates\SiteTemplate.pnp" -List "List name" -Recursive

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

3.22.x

How did you install the PnP-PowerShell Cmdlets?

cOberlaender commented 3 years ago

Can confirm this also exists in version 3.25 in PnP PowerShell for SharePoint 2016

kasperbolarsen commented 3 years ago

I have the same issue om 3.26 however the trace log seems to tell us that the file IS updated but saved to a wrong folder , one level up compared to the source:

I have verified that this file does contain the the folder refs as expected

PS C:\Users\kbl> $t = Add-PnPListFoldersToProvisioningTemplate -Path C:\temp\PnPTemplateTest\PnPTemplateTest.pnp -List "Documents" -Recursive powershell.exe Information: 0 : 2020-11-06 19.51.31.0415 [OfficeDevPnP.Core] [0] [Information] File PnPTemplateTest.pnp retrieved from folder 0ms powershell.exe Information: 0 : 2020-11-06 19.51.31.0498 [OfficeDevPnP.Core] [0] [Information] File PnPTemplateTest.pnp retrieved from folder 0ms powershell.exe Information: 0 : 2020-11-06 19.51.31.1025 [OfficeDevPnP.Core] [0] [Information] File PnPTemplateTest.xml retrieved from folder 0ms powershell.exe Error: 0 : 2020-11-06 19.51.35.1008 [OfficeDevPnP.Core] [0] [Error] File C:\temp\PnPTemplateTest.pnp not found in directory . Exception = Could not find file 'C:\temp\PnPTemplateTest.pnp'. 0ms powershell.exe Information: 0 : 2020-11-06 19.51.35.1886 [OfficeDevPnP.Core] [0] [Information] File PnPTemplateTest.xml saved to folder 0ms powershell.exe Information: 0 : 2020-11-06 19.51.35.2133 [OfficeDevPnP.Core] [0] [Information] File C:\temp\PnPTemplateTest.pnp saved to folder 0ms

dgoldbachhzd commented 3 years ago

We also have the same issue. When seeing the current sourcecode, i guess the problem lies within the following line:

XMLTemplateProvider provider = new XMLOpenXMLTemplateProvider(new OpenXMLConnector(outPath, fileSystemConnector));

of the file AddListFoldersToProvisioningTemplate.cs in the PnP.PowerShell.Core Project (line 106).

In comparison to the same line of the AddDataRowsToProvisioningTemplate.cs file (line 207) it seems obvious, that the path variable is the problem.

XMLTemplateProvider provider = new XMLOpenXMLTemplateProvider(new OpenXMLConnector(Path, fileSystemConnector));

Unfortunatly I am not able to build the project on my system to test the idea. Maybe someone can verify this or help me build the project?