-
Notifications
You must be signed in to change notification settings - Fork 381
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Reporting an Issue or Missing Feature
When running New-PnPSitetemplateFromFolder, a template is generated with files.
New-PnPSitetemplateFromFolder -Out "$PWD\site-template.xml" -Folder "$PWD\Files" -TargetFolder "some-target-folder" -Force
Results in:
<?xml version="1.0" encoding="utf-8"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2022/09/ProvisioningSchema">
<pnp:Preferences Generator="PnP.Framework, Version=1.11.141.0, Culture=neutral, PublicKeyToken=0d501f89f11b748c" />
<pnp:Templates ID="CONTAINER-FOLDEREXPORT">
<pnp:ProvisioningTemplate ID="FOLDEREXPORT" Version="0" Scope="Undefined">
<pnp:Files>
<pnp:File Src="ome-file.pdf" Folder="some-target-folder" Overwrite="true" Level="Draft" />
<pnp:File Src="some-file-2.pdf" Folder="some-target-folder" Overwrite="true" Level="Draft" />
</pnp:Files>
</pnp:ProvisioningTemplate>
</pnp:Templates>
</pnp:Provisioning>
The first character of the filenames are removed (ome-file.pdf instead of some-file.pdf) when building the template.
The cause of this is the following line in ..\powershell\src\Commands\Provisioning\Site\NewSiteTemplateFromFolder.cs
:
var unrootedPath = file.FullName.Substring(Folder.Length + 1);
The +1 is not needed here because .Substring()
is zero-indexed while Folder.Length
is not. The additional slash before the filename is therefore already ignored.
Expected behavior
I'd expect the full filenames
Actual behavior
The first character of the filenames are removed (ome-file.pdf instead of some-file.pdf) when building the template.
Steps to reproduce behavior
Run the script on a folder
What is the version of the Cmdlet module you are running?
1.11, 2.x nightly
Which operating system/environment are you running PnP PowerShell on?
- Windows
- Linux
- MacOS
- Azure Cloud Shell
- Azure Functions
- Other : please specify
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working