PNP Apply Template CSOM files not found

%3CLINGO-SUB%20id%3D%22lingo-sub-1136298%22%20slang%3D%22en-US%22%3EPNP%20Apply%20Template%20CSOM%20files%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1136298%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20to%20be%20able%20to%20apply%20pnp%20templates%20in%20CSOM%20with%20branding%20files%20exported%20from%20a%20site%2C%20please%20see%20below%20for%20details.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20doing%20the%20following%3C%2FP%3E%3COL%3E%3CLI%3EGetting%20Template%20and%20branding%20files%20using%20powershell%20with%3A%26nbsp%3B%20Get-PnPProvisioningTemplate%20-out%20%22testtemplate.xml%22%20-PersistBrandingFiles%3C%2FLI%3E%3CLI%3EUploading%20the%20xml%20and%20site%20assets%20folder%20to%20a%20document%20library%20in%20SharePoint%3C%2FLI%3E%3CLI%3EUsing%26nbsp%3BXMLSharePointTemplateProvider%20in%20CSOM%20C%23%20to%20get%20the%20template%20from%20SharePoint%3C%2FLI%3E%3CLI%3EApplying%20the%20template%20to%20a%20site%20using%26nbsp%3BWeb.ApplyProvisioningTemplate%20C%23%20CSOM%20(Issue)%3C%2FLI%3E%3C%2FOL%3E%3CP%3EMy%20issue%20is%20on%20step%204%20applying%20the%20template%2C%20the%20template%20cannot%20work%20out%20where%20the%20%2Fsiteassets%20folder%20is%20to%20retrieve%20the%20files%20it%20needs%20to%20upload%2C%20so%20I%20am%20getting%20a%20FileNotFound%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20works%20fine%20if%20i%20do%20not%20use%20the%20%22-persistBrandingFiles%22%20getting%20the%20template%2C%20however%20we%20need%20to%20get%20the%20files%20for%20other%20reasons.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20far%20as%20I%20am%20aware%20there%20is%20no%20way%20to%20apply%20a%20.pnp%20template%20file%20in%20CSOM%20C%23%20as%20all%20the%20examples%20only%20use%20xml.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3EAlex%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2032428%22%20slang%3D%22en-US%22%3ERe%3A%20PNP%20Apply%20Template%20CSOM%20files%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2032428%22%20slang%3D%22en-US%22%3E%3CP%3Edid%20you%20get%20any%20lead%20on%20this%20issue%3F%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F256067%22%20target%3D%22_blank%22%3E%40NotAlex%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2069414%22%20slang%3D%22en-US%22%3ERe%3A%20PNP%20Apply%20Template%20CSOM%20files%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2069414%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F918147%22%20target%3D%22_blank%22%3E%40mahendra2021%3C%2FA%3E%26nbsp%3B%20no%20I%20did%20not%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi All

 

I need to be able to apply pnp templates in CSOM with branding files exported from a site, please see below for details.

 

I am doing the following

  1. Getting Template and branding files using powershell with:  Get-PnPProvisioningTemplate -out "testtemplate.xml" -PersistBrandingFiles
  2. Uploading the xml and site assets folder to a document library in SharePoint
  3. Using XMLSharePointTemplateProvider in CSOM C# to get the template from SharePoint
  4. Applying the template to a site using Web.ApplyProvisioningTemplate C# CSOM (Issue)

My issue is on step 4 applying the template, the template cannot work out where the /siteassets folder is to retrieve the files it needs to upload, so I am getting a FileNotFound error.

 

It works fine if i do not use the "-persistBrandingFiles" getting the template, however we need to get the files for other reasons.

 

As far as I am aware there is no way to apply a .pnp template file in CSOM C# as all the examples only use xml. 

 

Any help would be appreciated.

 

Thanks

Alex

2 Replies

did you get any lead on this issue? @NotAlex 

@mahendra2021  no I did not