質問

Can I have the different sections of a PNP provisioning XML template in separate files and combine them when applying the template? Like having all lists in a lists.xml, refer to this list in the template, and when I decide to add another list to sites based on the templates using this list collections, I can just call the same provisioning script again.

My lists.xml looks like this:

<pnp:ListInstance Title="Announcements - {parameter:module}" Description="" DocumentTemplate="" TemplateType="104" Url="Lists/Announcements" MinorVersionLimit="0" MaxVersionLimit="0" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-d1ce-42de-9c63-a44004ce0104" EnableFolderCreation="false" DefaultDisplayFormUrl="{site}/Lists/Announcements/DispForm.aspx" DefaultEditFormUrl="{site}/Lists/Announcements/EditForm.aspx" DefaultNewFormUrl="{site}/Lists/Announcements/NewForm.aspx" ImageUrl="/_layouts/15/images/itann.png?rev=44" IsApplicationList="false" ValidationFormula="" ValidationMessage="">
  <pnp:ContentTypeBindings>
    <pnp:ContentTypeBinding ContentTypeID="0x0104" Default="true" />
    <pnp:ContentTypeBinding ContentTypeID="0x0120" />
  </pnp:ContentTypeBindings>
  <pnp:Views>
    <View Name="{guid}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All items" Url="Announcements/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/announce.png?rev=44">
      <Query>
        <OrderBy>
          <FieldRef Name="Modified" Ascending="FALSE" />
        </OrderBy>
      </Query>
      <ViewFields>
        <FieldRef Name="Attachments" />
        <FieldRef Name="LinkTitle" />
        <FieldRef Name="Modified" />
      </ViewFields>
      <RowLimit Paged="TRUE">30</RowLimit>
      <JSLink>clienttemplates.js</JSLink>
    </View>
  </pnp:Views>
  <pnp:FieldRefs>
    <pnp:FieldRef ID="{guid}" Name="_ComplianceFlags" DisplayName="Label setting" />
    <pnp:FieldRef ID="{guid}" Name="_ComplianceTag" DisplayName="Labels" />
    <pnp:FieldRef ID="{guid}" Name="_ComplianceTagWrittenTime" DisplayName="Label Applied" />
    <pnp:FieldRef ID="{guid}" Name="_ComplianceTagUserId" DisplayName="Label applied by" />
    <pnp:FieldRef ID="{guid}" Name="_IsRecord" DisplayName="Item is a Record" />
    <pnp:FieldRef ID="{guid}" Name="ComplianceAssetId" DisplayName="Compliance Asset Id" />
    <pnp:FieldRef ID="{guid}" Name="Body" DisplayName="Body" />
    <pnp:FieldRef ID="{guid}" Name="Expires" DisplayName="Expires" />
  </pnp:FieldRefs>
</pnp:ListInstance>

I added a parameter to my provisioning template under the pnp:Lists element:

<pnp:Lists>
{parameter:lists}
</pnp:Lists>

I tried adding the file content as parameter like:

$pnpLists = get-content -Path ".\lists.xml"
Apply-PnPProvisioningTemplate -ClearNavigation -Path $template -Verbose -Parameters @{"pnplists"="$pnplists"}

The file is read, but during provisioning, I get a PowerShell_ISE.exe Error: 0 : 2018-07-05 17:55:33.5138 [SchemaFormatter] [0] [Error] Template is not valid: The element 'ListInstance' in namespace 'http://schemas.dev.office.com/PnP/2018/05/ProvisioningSchema' cannot contain text. List of possible elements expected: 'IRMSettings, FieldRefs, Fields, DataSource, DataRows, FieldDefaults, UserCustomActions, Folders, Webhooks, Security' in namespace 'http://schemas.dev.office.com/PnP/2018/05/ProvisioningSchema'. error.

役に立ちましたか?

解決

In case someone else is looking for an answer. Tbe solution was already there on GitHub, but, probably only for me, hard to found, if not specially looking for xi:include. The PNP provisioning enginge supports the this command. Example is here. Syntax:

<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Objects/SiteFields.xml"/>

You also need to add the PnP namespace to the included xml:

<?xml version="1.0" encoding="utf-8" ?>
<pnp:PropertyBagEntries xmlns:pnp="http://schemas.dev.office.com/PnP/2015/05/ProvisioningSchema">
  <pnp:PropertyBagEntry Key="KEY1" Value="value1" />
  <pnp:PropertyBagEntry Key="KEY2" Value="value2" />
</pnp:PropertyBagEntries>

他のヒント

As the error states the xml is not valid. You will need the full schema hierarchy. You should probably have a look at https://github.com/SharePoint/PnP-Provisioning-Schema/blob/master/ProvisioningSchema-2018-05.md#templates

And more specifically the ProvisioningTemplateFile part.

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top