如何查找清单元素的正确顺序How to find the proper order of manifest elements

Office 外接程序清单中的 XML 元素必须位于正确父元素下, 在父元素下以特定的相对顺序存在。The XML elements in the manifest of an Office Add-in must be under the proper parent element and in a specific order, relative to each other, under the parent.

所需的排序在 Schemas 文件夹的 XSD 文件中指定。The required ordering is specified in the XSD files in the Schemas folder. XSD 文件分类存放在对应任务窗格、内容和邮件三类外接程序的子文件夹中。The XSD files are categorized into subfolders for taskpane, content, and mail add-ins.

例如,在 <OfficeApp> 元素中,<Id><Version><ProviderName> 必须按此顺序出现。For example, in the <OfficeApp> element, the <Id>, <Version>, <ProviderName> must appear in that order. 如果添加了 <AlternateId> 元素,则其必须位于 <Id><Version> 元素之间。If an <AlternateId> element is added, it must be between the <Id> and <Version> element. 如果任何元素的顺序出错,清单将无效并且你的外接程序将无法加载。Your manifest will not be valid and your add-in will not load, if any element is in the wrong order.

备注

当元素顺序有误时 ,office-addin-manifest 中的验证程序会使用相同的错误消息,因为元素位于错误的父元素下。The validator within office-addin-manifest uses the same error message when an element is out-of-order as it does when an element is under the wrong parent. 该错误消息会提示子元素不是父元素的有效子级。The error says the child element is not a valid child of the parent element. 如果出现此类错误,而子元素的参考文档却指示它对父级 有效的,则问题很可能是子级的放置顺序出现了错误。If you get such an error but the reference documentation for the child element indicates that it is valid for the parent, then the problem is likely that the child has been placed in the wrong order.

以下各节按清单元素的显示顺序显示这些元素。The following sections show the manifest elements in the order in which they must appear. 根据元素的属性是 、还是不同, type <OfficeApp> 存在 TaskPaneApp ContentApp 差异 MailAppThere are differences depending on whether the type attribute of the <OfficeApp> element is TaskPaneApp, ContentApp, or MailApp. 若要阻止这些部分变得过于不工作,将高度复杂的元素分为 <VersionOverrides> 单独的部分。To keep these sections from becoming too unwieldy, the highly complex <VersionOverrides> element is broken out into separate sections.

备注

并非所有显示的元素都是强制性的。Not all of the elements shown are mandatory. 如果在 minOccurs 架构中某个元素的值为 0, 则此元素是可选的。 If the minOccurs value for a element is 0 in the schema, the element is optional.

基本任务窗格加载项元素排序Basic task pane add-in element ordering

<OfficeApp xsi:type="TaskPaneApp">
    <Id>
    <AlternateID>
    <Version>
    <ProviderName>
    <DefaultLocale>
    <DisplayName>
        <Override>
    <Description>
        <Override>
    <IconUrl>
        <Override>
    <HighResolutionIconUrl>
        <Override>
    <SupportUrl>
    <AppDomains>
        <AppDomain>
    <Hosts>
        <Host>
    <Requirements>
        <Sets>
            <Set>
        <Methods>
            <Method>
    <DefaultSettings>
        <SourceLocation>
            <Override>
    <Permissions>
    <Dictionary>
        <TargetDialects>
        <QueryUri>
        <CitationText>
        <DictionaryName>
        <DictionaryHomePage>
    <VersionOverrides>*
    <ExtendedOverrides>

*有关 VersionOverrides 的子元素的排序,请参阅 VersionOverrides 中的任务窗格加载项元素排序。*See Task pane add-in element ordering within VersionOverrides for the ordering of children elements of VersionOverrides.

基本邮件外接程序元素排序Basic mail add-in element ordering

<OfficeApp xsi:type="MailApp">
    <Id>
    <AlternateId>
    <Version>
    <ProviderName>
    <DefaultLocale>
    <DisplayName>
        <Override>
    <Description>
        <Override>
    <IconUrl>
        <Override>
    <HighResolutionIconUrl>
        <Override>
    <SupportUrl>
    <AppDomains>
        <AppDomain>
    <Hosts>
        <Host>
    <Requirements>
    <Sets>
        <Set>
    <FormSettings>
        <Form>
        <DesktopSettings>
            <SourceLocation>
            <RequestedHeight>
        <TabletSettings>
            <SourceLocation>
            <RequestedHeight>
        <PhoneSettings>
            <SourceLocation>
    <Permissions>
    <Rule>
    <DisableEntityHighlighting>
    <VersionOverrides>*

*有关 VersionOverrides 的子元素排序,请参阅 VersionOverrides Ver. 1.0 中的 Mail 加载项元素排序和 VersionOverrides Ver. 1.1 中的邮件外接程序元素排序。*See Mail add-in element ordering within VersionOverrides Ver. 1.0 and Mail add-in element ordering within VersionOverrides Ver. 1.1 for the ordering of children elements of VersionOverrides.

基本内容加载项元素排序Basic content add-in element ordering

<OfficeApp xsi:type="ContentApp">
    <Id>
    <AlternateId>
    <Version>
    <ProviderName>
    <DefaultLocale>
    <DisplayName>
        <Override>
    <Description>
        <Override>
    <IconUrl >
        <Override>
    <HighResolutionIconUrl>
        <Override>
    <SupportUrl>
    <AppDomains>
        <AppDomain>
    <Hosts>
        <Host>
    <Requirements>
    <Sets>
        <Set>
    <Methods>
        <Method>
    <DefaultSettings>
        <SourceLocation>
            <Override>
    <RequestedWidth>
    <RequestedHeight>
    <Permissions>
    <AllowSnapshot>
    <VersionOverrides>*

*有关 VersionOverrides 的子元素的排序,请参阅 VersionOverrides 中的内容加载项元素排序。*See Content add-in element ordering within VersionOverrides for the ordering of children elements of VersionOverrides.

VersionOverrides 中的任务窗格加载项元素排序Task pane add-in element ordering within VersionOverrides

<VersionOverrides>
    <Description>
    <Requirements>
        <Sets>
            <Set>
    <Hosts>
        <Host>
            <Runtimes>
                <Runtime>
            <AllFormFactors>
                <ExtensionPoint>
                    <Script>
                        <SourceLocation>
                    <Page>
                        <SourceLocation>
                    <Metadata>
                        <SourceLocation>
                    <Namespace>
            <DesktopFormFactor>
                <GetStarted>
                    <Title>
                    <Description>
                    <LearnMoreUrl>
                <FunctionFile>
                <ExtensionPoint>
                    <OfficeTab>
                        <Group>
                            <Label>
                            <Icon>
                                <Image>
                            <Control>
                            <Label>
                            <Supertip>
                                <Title>
                                <Description>
                            <Icon>
                                <Image>  
                            <Action>
                                <TaskpaneId>
                                <SourceLocation>
                                <Title>
                                <FunctionName>
                            <Enabled>
                            <Items>
                                <Item>
                                <Label>
                                <Supertip>
                                    <Title>
                                    <Description>
                                <Action>
                                    <TaskpaneId>
                                    <SourceLocation>
                                    <Title>
                                    <FunctionName>
                    <CustomTab>
                        <OverriddenByRibbonApi>
                        <Group> (can be below <ControlGroup>)
                            <OverriddenByRibbonApi>
                            <Label>
                            <Icon>
                                <Image>
                            <Control>
                                <OverriddenByRibbonApi>
                                <Label>
                                <Supertip>
                                    <Title>
                                    <Description>
                                <Icon>
                                    <Image>  
                                <Action>
                                    <TaskpaneId>
                                    <SourceLocation>
                                    <Title>
                                    <FunctionName>
                                <Enabled>
                                <Items>
                                    <Item>
                                        <OverriddenByRibbonApi>
                                        <Label>
                                        <Supertip>
                                            <Title>
                                            <Description>
                                        <Action>
                                            <TaskpaneId>
                                            <SourceLocation>
                                            <Title>
                                            <FunctionName>
                        <ControlGroup> (can be above <Group>)
                        <Label>
                        <InsertAfter> (or <InsertBefore>)
                    <OfficeMenu>
                        <Control>
                            <Label>
                            <Supertip>
                                <Title>
                                <Description>
                            <Icon>
                                <Image>  
                            <Action>
                                <TaskpaneId>
                                <SourceLocation>
                                <Title>
                                <FunctionName>
                            <Enabled>
                            <Items>
                                <Item>
                                    <Label>
                                    <Supertip>
                                        <Title>
                                        <Description>
                                    <Action>
                                        <TaskpaneId>
                                        <SourceLocation>
                                        <Title>
                                        <FunctionName>
        <Resources>
            <Images>
                <Image>
                    <Override>
            <Urls>
                <Url>
                    <Override>
            <ShortStrings>
                <String>
                    <Override>
            <LongStrings>
                <String>
                    <Override>
        <WebApplicationInfo>
            <Id>
            <MsaId>
            <Resource>
            <Scopes>
                <Scope>
            <Authorizations>
                <Authorization>
                    <Resource>
                    <Scopes>
                        <Scope>
        <EquivalentAddins>
            <EquivalentAddin>
                <ProgId>
                <DisplayName>
                <FileName>
                <Type>

VersionOverrides Ver 中的邮件外接程序元素排序。Mail add-in element ordering within VersionOverrides Ver. 1.01.0

<VersionOverrides>
    <Description>
    <Requirements>
        <Sets>
            <Set>
    <Hosts>
        <Host>
            <DesktopFormFactor>
                <ExtensionPoint>
                    <OfficeTab>
                        <Group>
                            <Label>
                            <Control>
                                <Label>
                                <Supertip>
                                    <Title>
                                    <Description>
                                <Icon>
                                    <Image>
                                <Action>
                                    <SourceLocation>
                                    <FunctionName>
                    <CustomTab>
                        <Group>
                            <Label>
                            <Icon>
                                <Image>
                            <Control>
                                <Label>
                                <Supertip>
                                    <Title>
                                    <Description>
                                <Icon>
                                    <Image>  
                                <Action>
                                    <TaskpaneId>
                                    <SourceLocation>
                                    <Title>
                                    <FunctionName>
                                <Items>
                                    <Item>
                                        <Label>
                                        <Supertip>
                                            <Title>
                                            <Description>
                                        <Action>
                                            <TaskpaneId>
                                            <SourceLocation>
                                            <Title>
                                            <FunctionName>
                        <Label>
                    <OfficeMenu>
                        <Control>
                            <Label>
                            <Supertip>
                                <Title>
                                <Description>
                            <Icon>
                                <Image>
                            <Action>
                                <TaskpaneId>
                                <SourceLocation>
                                <Title>
                                <FunctionName>
                            <Items>
                                <Item>
                                    <Label>
                                    <Supertip>
                                        <Title>
                                        <Description>
                                    <Action>
                                        <TaskpaneId>
                                        <SourceLocation>
                                        <Title>
                                        <FunctionName>
    <Resources>
        <Images>
            <Image>
                <Override>
        <Urls>
            <Url>
                <Override>
        <ShortStrings>
            <String>
                <Override>
        <LongStrings>
            <String>
                <Override>
    <VersionOverrides>*

* 具有值而不是值的 VersionOverrides 可以嵌套在 type VersionOverridesV1_1 外部 VersionOverridesV1_0 VersionOverrides 的末尾。* A VersionOverrides with type value VersionOverridesV1_1, instead of VersionOverridesV1_0, can be nested at the end of the outer VersionOverrides. 有关 中元素的排序,请参阅 VersionOverrides Ver. 1.1 中的 Mail 加载项元素排序 VersionOverridesV1_1See Mail add-in element ordering within VersionOverrides Ver. 1.1 for the ordering of elements in VersionOverridesV1_1.

VersionOverrides Ver 中的邮件外接程序元素排序。Mail add-in element ordering within VersionOverrides Ver. 1.11.1

<VersionOverrides>
    <Description>
    <Requirements>
    <Sets>
        <Set>
    <Hosts>
    <Host>
        <DesktopFormFactor>
            <ExtensionPoint>
                <OfficeTab>
                    <Group>
                        <Label>
                        <Control>
                            <Label>
                            <Supertip>
                                <Title>
                                <Description>
                            <Icon>
                                <Image>
                            <Action>
                                <SourceLocation>
                                <FunctionName>
                <CustomTab>
                    <Group>
                        <Label>
                        <Icon>
                            <Image>
                        <Control>
                            <Label>
                            <Supertip>
                                <Title>
                                <Description>
                            <Icon>
                                <Image>  
                            <Action>
                                <TaskpaneId>
                                <SourceLocation>
                                <Title>
                                <FunctionName>
                            <Items>
                                <Item>
                                    <Label>
                                    <Supertip>
                                        <Title>
                                        <Description>
                                    <Action>
                                        <TaskpaneId>
                                        <SourceLocation>
                                        <Title>
                                        <FunctionName>
                    <Label>
                <OfficeMenu>
                    <Control>
                        <Label>
                        <Supertip>
                            <Title>
                            <Description>
                        <Icon>
                            <Image>  
                        <Action>
                            <TaskpaneId>
                            <SourceLocation>
                            <Title>
                            <FunctionName>
                        <Items>
                            <Item>
                                <Label>
                                <Supertip>
                                    <Title>
                                    <Description>
                                <Action>
                                    <TaskpaneId>
                                    <SourceLocation>
                                    <Title>
                                    <FunctionName>
                                    <SourceLocation>
                <SourceLocation>
                <Label>
                <CommandSurface>
    <Resources>
        <Images>
            <Image>
                <Override>
        <Urls>
            <Url>
                <Override>
        <ShortStrings>
            <String>
                <Override>
        <LongStrings>
            <String>
                <Override>
    <WebApplicationInfo>
        <Id>
        <Resource>
        <Scopes>
            <Scope>

VersionOverrides 中的内容加载项元素排序Content add-in element ordering within VersionOverrides

<VersionOverrides>
    <WebApplicationInfo>
        <Id>
        <Resource>
        <Scopes>
            <Scope>

另请参阅See also