pnp / pnpframework

PnP Framework is a .NET library targeting Microsoft 365 containing the PnP Provisioning engine and a ton of other useful extensions
https://pnp.github.io/pnpframework/
MIT License
200 stars 140 forks source link

Unable to provision a site using .pnp template #821

Open PrasadMadhavan opened 1 year ago

PrasadMadhavan commented 1 year ago

I am trying to provision a SharePoint Online sitecollection with template.pnp with CSOM. It fails at Provider.GetTemplate step given below. . The error says "Provisioning Template URI is not valid". It works fine when I use template.xml file instead. But this approach won't help me apply the branding files, logo etc. This used to work fine with .PnP files when we were using OfficeDevPnP.Core. The issue occurs only when we replaced it with the latest PnP.Framework.

provider = new XMLOpenXMLTemplateProvider( new OpenXMLConnector(templateRelativePath, sharepointConnector));

ProvisioningTemplate template = provider.GetTemplate(templateRelativePath);

Please note, I tried the same approach on PnP.Powershell, and got a very similar behaviour, please see below.

Invoke-PnPSiteTemplate -Path C:\Dev\MAB\template.pnp Invoke-PnPSiteTemplate: The Provisioning Template URI template.xml is not valid._

Can you please advise? Please let me know if you need any additional info.

PrasadMadhavan commented 1 year ago

Hello - I really appreciate if you can help with your guidance on this. My deployment is on hold due to this issue. Any input that you can provide will help me decide on an approach on how to address this problem.

enthusol commented 1 year ago

I recently had the same error message while using "Invoke-PnPSiteTemplate". It appeared after renaming of the PnP file after exporting it. When the name of the PnP file did not change since exporting it, evereything works fine. Maybe you can observe that; hope this helps ...

ChrisJustice90 commented 6 days ago

As soon as I try to load a .pnp file, I receive the following error:

System.Xml.XmlException: Root element is missing. [2024-07-03T16:08:38.262Z] at System.Xml.XmlTextReaderImpl.Throw(Exception e) [2024-07-03T16:08:38.263Z] at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res) [2024-07-03T16:08:38.264Z] at System.Xml.XmlTextReaderImpl.ParseDocumentContent() [2024-07-03T16:08:38.265Z] at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) [2024-07-03T16:08:38.266Z] at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options) [2024-07-03T16:08:38.268Z] at PnP.Framework.Provisioning.Providers.Xml.XMLTemplateProvider.ResolveXIncludes(Stream stream) [2024-07-03T16:08:38.268Z] at PnP.Framework.Provisioning.Providers.Xml.XMLTemplateProvider.GetTemplate(Stream stream, String identifier, ITemplateFormatter formatter, ITemplateProviderExtension[] extensions) [2024-07-03T16:08:38.269Z] at PnP.Framework.Provisioning.Providers.Xml.XMLTemplateProvider.GetTemplate(Stream stream, ITemplateProviderExtension[] extensions) [2024-07-03T16:08:38.270Z] at PnP.Framework.Provisioning.Providers.Xml.XMLTemplateProvider.GetTemplate(Stream stream)

Heres my code:

var fileSystemConnector = new FileSystemConnector(templateFilePath, "");
Stream pnpFileStream = new FileStream(fullTemplateFile, FileMode.Open);

var openXmlConnector = new OpenXMLConnector(pnpFileStream);
var provider = new XMLOpenXMLTemplateProvider(openXmlConnector);

var template = provider.GetTemplate(pnpFileStream);