SOLVED

apply pnp template on sub site

%3CLINGO-SUB%20id%3D%22lingo-sub-25657%22%20slang%3D%22en-US%22%3Eapply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25657%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI%20extracted%20a%20.pnp%20template%20from%20a%20sub%20site%20(publishing)%20%26nbsp%3Band%20then%20tried%20to%20apply%20that%20.pnp%20template%20to%20a%20newly%20created%20sub%20site%20(publishing)%20but%20I%20could%20not%20do%20this%2C%3C%2FP%3E%3CP%3Ewhen%20I%20try%20to%20apply%20from%20power%20shell%20or%20C%23%20console%20application%20it%20shows%20this%20error%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F7782i4FD2BED7BC518401%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22applying%20absencevacationrequest%20template%20on%20a%20subsite%20of%20a%20Team%20site.png%22%20title%3D%22applying%20absencevacationrequest%20template%20on%20a%20subsite%20of%20a%20Team%20site.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20tried%20by%20downloading%20the%20pnp%20core%20source%20code%20and%20found%20that%20file%20stream%20is%20missing%20there%2C%20how%20can%20I%20solve%20this%20issue%3F%20Please%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20a%20screenshot%20of%20powershell%20window%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20923px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F7783i9E9627C9413B4B27%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%222016-10-29%2015_53_08-Administrator_%20Windows%20PowerShell%20ISE.png%22%20title%3D%222016-10-29%2015_53_08-Administrator_%20Windows%20PowerShell%20ISE.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-25657%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-26049%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-26049%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Jess%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eplease%20make%20sure%20youre%20files%20are%20in%20the%20correct%20directory%20aka%20the%20bin%20directory%20where%20your%20console%20is%20running.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ekr%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPaul%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-26035%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-26035%22%20slang%3D%22en-US%22%3E%3CP%3E%40Deleted%26nbsp%3Bone%20thing%2C%20I%20told%20you%20it%20works%2C%20but%20it%20only%20works%20from%20PowerShell%20but%20not%20from%20C%23%20console%20application%2C%20can%20you%20give%20any%20clue%3F%20By%20the%20way%2C%20this%20time%20I%20am%20using%20.pnp%20template.%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-26028%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-26028%22%20slang%3D%22en-US%22%3EThanks%2C%20I'll%20have%20a%20look%20into%20the%20article.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-26027%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-26027%22%20slang%3D%22en-US%22%3EThanks%20a%20lot%20for%20your%20help.%20When%20I%20modified%20file%20src%20from%20%22default.aspx%22%20to%20%22Pages%5Cdefault.aspx%22%20it%20worked!%20I%20don't%20know%20why%20provisioning%20engine%20does%20not%20giving%20the%20correct%20path%20for%20file%20src.%20May%20be%20I%20am%20extracting%20template%20from%20sub%20site%2C%20that's%20why.%3CBR%20%2F%3E%3CBR%20%2F%3EAnyway%2C%20thanks%20for%20the%20big%20help.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25861%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25861%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F26607%22%20target%3D%22_blank%22%3E%40Jess%20Lassen%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20easiest%20way%20to%20debug%20this%20is%20using%20PowerShell%20Set-SPOTraceLog.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fveenstra.me.uk%2F2016%2F07%2F29%2Foffice-365-sharepoint-how-to-debug-pnp-provisioning-engine%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fveenstra.me.uk%2F2016%2F07%2F29%2Foffice-365-sharepoint-how-to-debug-pnp-provisioning-engine%2F%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25843%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25843%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eit%20seems%20the%20pages%20are%20not%20in%20the%20current%20directory.%20My%20pnp%3Afiles%20look%20like%20this%3C%2FP%3E%3CP%3E%3CFILE%20src%3D%22%26quot%3BSiteAssets%5CLogo.png%26quot%3B%22%20folder%3D%22%26quot%3BSiteAssets%26quot%3B%22%20overwrite%3D%22%26quot%3Btrue%26quot%3B%22%3E%3C%2FFILE%3E%3C%2FP%3E%3CP%3Ewhere%20src%20could%20be%20C%3A%5Ctemp%5Csitesassets%5Clogo.png%3C%2FP%3E%3CP%3Eso%20whitout%20properties%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ebut%20also%20do%20you%20need%20to%20provision%20the%20masterpages%3F%20If%20they%20are%20already%20in%20there%20why%20would%20you%20like%20to%20upload%20your%20version%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ehope%20it%20helps.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25837%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25837%22%20slang%3D%22en-US%22%3EThanks%20for%20your%20reply%2C%20my%20template%20works%20if%20I%20remove%20the%20whole%20Files%20section%20from%20the%20xml.%20But%20if%20I%20need%20to%20provision%20the%20files%20what%20should%20I%20do%3F%20Can%20you%20please%20let%20me%20know%3F%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20for%20your%20help%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25827%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25827%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Elooked%20at%20your%20template%20and%20what%20i%20would%20do%20narrow%20it%20down%20meaning%20remove%20parts%20of%20the%20xml%20like%20what%20happeens%20if%20all%20is%20commented%20out%20except%20time...%20etc..%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Efurthermore%20i%20see%20this%20line%3A%3C%2FP%3E%3CP%3E%3CPROPERTY%20key%3D%22%26quot%3BPublishingPageLayout%26quot%3B%22%20value%3D%22%26quot%3B%7Bsitecollection%7D%2F_catalogs%2Fmasterpage%2Fwizdom2Column.aspx%2C%22%3E%3CA%20href%3D%22https%3A%2F%2Fxxxx.sharepoint.com%2Fsites%2Frayhan%7Bsitecollection%7D%2F_catalogs%2Fmasterpage%2Fwizdom2Column.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fxxxx.sharepoint.com%2Fsites%2Frayhan%7Bsitecollection%7D%2F_catalogs%2Fmasterpage%2Fwizdom2Column.aspx%3C%2FA%3E%22%20%2F%26gt%3B%3C%2FPROPERTY%3E%3C%2FP%3E%3CP%3EWher%20you%20use%20a%20url%20and%20a%20sitecolleciton%20token%20in%201%20url...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25809%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25809%22%20slang%3D%22en-US%22%3E%3CP%3E%40Deleted%26nbsp%3BI%20did%20not%20rename%20anything.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20see%20the%20following%20screen%20shots%20what%20I%20did%20(all%20using%20power%20shell)%3C%2FP%3E%3CP%3EExtracted%20template%20from%20site%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20550px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F7840i4C50B1AFA3B0A116%2Fimage-dimensions%2F550x266%3Fv%3D1.0%22%20width%3D%22550%22%20height%3D%22266%22%20alt%3D%222016-10-31%2012_57_23-Administrator_%20Windows%20PowerShell%20ISE.png%22%20title%3D%222016-10-31%2012_57_23-Administrator_%20Windows%20PowerShell%20ISE.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EApplying%20template%20started%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20624px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F7841i26C25094AFF12152%2Fimage-dimensions%2F624x311%3Fv%3D1.0%22%20width%3D%22624%22%20height%3D%22311%22%20alt%3D%222016-10-31%2013_02_01-Administrator_%20Windows%20PowerShell%20ISE.png%22%20title%3D%222016-10-31%2013_02_01-Administrator_%20Windows%20PowerShell%20ISE.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ETemplate%20applying%20started%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EApplying%20template%20fails%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20628px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F7842i67ACCF853CEFC539%2Fimage-dimensions%2F628x183%3Fv%3D1.0%22%20width%3D%22628%22%20height%3D%22183%22%20alt%3D%222016-10-31%2013_06_30-Administrator_%20Windows%20PowerShell%20ISE.png%22%20title%3D%222016-10-31%2013_06_30-Administrator_%20Windows%20PowerShell%20ISE.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EApplying%20template%20fails%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20attaching%20the%20.xml%20template%20file%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25803%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25803%22%20slang%3D%22en-US%22%3E%3CP%3EOk%20that%20is%20another%20question.%20did%20you%20try%20to%20rename%20the%20default.aspx%20just%20to%20try%20it%20and%20remove%20the%20webparts..%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25802%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25802%22%20slang%3D%22en-US%22%3E%3CP%3E%40Deleted%26nbsp%3BI%20checked%20it%20is%20loaded%20when%20I%20tried%20to%20apply%20it%20from%20debug%20mode.%20It%20applies%20list%20instances%20and%20when%20it%20tries%20to%20apply%20Files%20(default.aspx)%20it%20fails%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25800%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25800%22%20slang%3D%22en-US%22%3E%3CP%3EIt%20is%20strange.%20It%20looks%20like%20the%20path%20does%20not%20exist.%20Did%20you%20check%20the%20template%20with%20the%20loaded%20schema%20if%20not%20working%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25798%22%20slang%3D%22en-US%22%3ERe%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25798%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F369%22%20target%3D%22_blank%22%3E%40Vesa%20Juvonen%3C%2FA%3E%26nbsp%3BCan%20you%20please%20help%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25796%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25796%22%20slang%3D%22en-US%22%3EHi%2C%20I%20double%20checked%20and%20the%20template%20is%20the%20desired%20directory.%20Any%20help%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-25744%22%20slang%3D%22en-US%22%3ERE%3A%20apply%20pnp%20template%20on%20sub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-25744%22%20slang%3D%22en-US%22%3EIt%20seems%20your%20Template%20is%20not%20in%20the%20right%20directory%20at%20least%20it%20can%20not%20find%20it%20in%20the%20directory%20you%20think%20it%20is.%20check%20the%20path%20and%20check%20if%20the%20template%20is%20in%20this%20location.%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi, 

I extracted a .pnp template from a sub site (publishing)  and then tried to apply that .pnp template to a newly created sub site (publishing) but I could not do this,

when I try to apply from power shell or C# console application it shows this error

 

applying absencevacationrequest template on a subsite of a Team site.png

I tried by downloading the pnp core source code and found that file stream is missing there, how can I solve this issue? Please help.

 

Here is a screenshot of powershell window

2016-10-29 15_53_08-Administrator_ Windows PowerShell ISE.png

 

 

15 Replies
It seems your Template is not in the right directory at least it can not find it in the directory you think it is. check the path and check if the template is in this location.
Hi, I double checked and the template is the desired directory. Any help?

@Vesa Juvonen Can you please help?

It is strange. It looks like the path does not exist. Did you check the template with the loaded schema if not working?

@Deleted I checked it is loaded when I tried to apply it from debug mode. It applies list instances and when it tries to apply Files (default.aspx) it fails

Ok that is another question. did you try to rename the default.aspx just to try it and remove the webparts..

 

@Deleted I did not rename anything.

 

Please see the following screen shots what I did (all using power shell)

Extracted template from site 

2016-10-31 12_57_23-Administrator_ Windows PowerShell ISE.png

 

Applying template started

Template applying startedTemplate applying started

Applying template fails

Applying template failsApplying template fails

 

I am attaching the .xml template file

Thanks

Hi,

 

looked at your template and what i would do narrow it down meaning remove parts of the xml like what happeens if all is commented out except time... etc..

 

furthermore i see this line:

<pnp:Property Key="PublishingPageLayout" Value="{sitecollection}/_catalogs/masterpage/wizdom2Column.aspx, https://xxxx.sharepoint.com/sites/rayhan{sitecollection}/_catalogs/masterpage/wizdom2Column.aspx" />

Wher you use a url and a sitecolleciton token in 1 url...

 

 

Thanks for your reply, my template works if I remove the whole Files section from the xml. But if I need to provision the files what should I do? Can you please let me know?

Thanks for your help
best response confirmed by Jess Lassen (Occasional Contributor)
Solution

Hi,

 

it seems the pages are not in the current directory. My pnp:files look like this

<pnp:File src="SiteAssets\Logo.png" Folder="SiteAssets" Overwrite="true" />

where src could be C:\temp\sitesassets\logo.png

so whitout properties

 

but also do you need to provision the masterpages? If they are already in there why would you like to upload your version?

 

hope it helps.

Hi @Jess Lassen,

 

The easiest way to debug this is using PowerShell Set-SPOTraceLog.

 

https://veenstra.me.uk/2016/07/29/office-365-sharepoint-how-to-debug-pnp-provisioning-engine/

 

Thanks a lot for your help. When I modified file src from "default.aspx" to "Pages\default.aspx" it worked! I don't know why provisioning engine does not giving the correct path for file src. May be I am extracting template from sub site, that's why.

Anyway, thanks for the big help.
Thanks, I'll have a look into the article.

@Deleted one thing, I told you it works, but it only works from PowerShell but not from C# console application, can you give any clue? By the way, this time I am using .pnp template. 

Thanks

Hi Jess,

 

please make sure youre files are in the correct directory aka the bin directory where your console is running.

 

kr,

 

Paul