无法指定为 OfficeApp manifest.xml 设置的要求

Can't specify requirements set for OfficeApp manifest.xml

我有一个 Office add-in/TaskPane 应用程序。

当我尝试在我的 manifest.xml 中指定为此应用程序设置的要求时,我收到来自 office-addin-validator 的以下错误:

The element OfficeApp in namespace http://schemas.microsoft.com/office/appforoffice/1.1 has invalid child element Requirements in namespace http://schemas.microsoft.com/office/appforoffice/1.1

The documentation 非常清楚 Requirements 实际上是允许出现在这个位置的。

我可以在 VersionOverrides 标签内添加要求集,该部分如下所示:

<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Requirements>
        <bt:Sets>
            <bt:Set Name="ExcelApi" MinVersion="1.1"/>
        </bt:Sets>
    </Requirements>
    <!--- ... -->
</VersionOverrides>

但是,office-addin-validator 无法正确识别旧版本的 Excel 不受支持。

正确的做法是什么?我无法判断这是 office-addin-validator 工具中的错误还是过时的文档。

编辑

这是一个失败的清单:

<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" 
    xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">

    <Id>999dfa02-364b-450c-a66b-b4baaae2e6f9</Id>
    <Version>1.0.0.0</Version>
    <ProviderName>[Provider name]</ProviderName>
    <DefaultLocale>en-US</DefaultLocale>
    <DisplayName DefaultValue="My Office Add-in" />
    <Description DefaultValue="[Workbook Add-in description]"/>
    <IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png" />
    <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/hi-res-icon.png"/>
    <SupportUrl DefaultValue="[Insert the URL of a page that provides support information for the app]"/>
    <AppDomains>
        <AppDomain>AppDomain1</AppDomain>
        <AppDomain>AppDomain2</AppDomain>
        <AppDomain>AppDomain3</AppDomain>
    </AppDomains>
    <Hosts>
        <Host Name="Workbook" />
    </Hosts>
    <DefaultSettings>
        <SourceLocation DefaultValue="https://localhost:3000/index.html" />
    </DefaultSettings>
    <Permissions>ReadWriteDocument</Permissions>
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
        <Hosts>
            <Host xsi:type="Workbook">
                <DesktopFormFactor>
                    <GetStarted>
                        <Title resid="Contoso.GetStarted.Title"/>
                        <Description resid="Contoso.GetStarted.Description"/>
                        <LearnMoreUrl resid="Contoso.GetStarted.LearnMoreUrl"/>
                    </GetStarted>
                    <FunctionFile resid="Contoso.DesktopFunctionFile.Url" />
                    <ExtensionPoint xsi:type="PrimaryCommandSurface">
                        <OfficeTab id="TabHome">
                            <Group id="Contoso.Group1">
                                <Label resid="Contoso.Group1Label" />
                                <Icon>
                                    <bt:Image size="16" resid="Contoso.tpicon_16x16" />
                                    <bt:Image size="32" resid="Contoso.tpicon_32x32" />
                                    <bt:Image size="80" resid="Contoso.tpicon_80x80" />
                                </Icon>
                                <Control xsi:type="Button" id="Contoso.TaskpaneButton">
                                    <Label resid="Contoso.TaskpaneButton.Label" />
                                    <Supertip>
                                        <Title resid="Contoso.TaskpaneButton.Label" />
                                        <Description resid="Contoso.TaskpaneButton.Tooltip" />
                                    </Supertip>
                                    <Icon>
                                        <bt:Image size="16" resid="Contoso.tpicon_16x16" />
                                        <bt:Image size="32" resid="Contoso.tpicon_32x32" />
                                        <bt:Image size="80" resid="Contoso.tpicon_80x80" />
                                    </Icon>
                                    <Action xsi:type="ShowTaskpane">
                                        <TaskpaneId>ButtonId1</TaskpaneId>
                                        <SourceLocation resid="Contoso.Taskpane.Url" />
                                    </Action>
                                </Control>
                            </Group>
                        </OfficeTab>
                    </ExtensionPoint>
                </DesktopFormFactor>
            </Host>
        </Hosts>
        <Resources>
            <bt:Images>
                <bt:Image id="Contoso.tpicon_16x16" DefaultValue="https://localhost:3000/assets/icon-16.png" />
                <bt:Image id="Contoso.tpicon_32x32" DefaultValue="https://localhost:3000/assets/icon-32.png" />
                <bt:Image id="Contoso.tpicon_80x80" DefaultValue="https://localhost:3000/assets/icon-80.png" />
            </bt:Images>
            <bt:Urls>
                <bt:Url id="Contoso.Taskpane.Url" DefaultValue="https://localhost:3000/index.html" />
                <bt:Url id="Contoso.GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812" />
                <bt:Url id="Contoso.DesktopFunctionFile.Url" DefaultValue="https://localhost:3000/function-file/function-file.html" />
            </bt:Urls>
            <bt:ShortStrings>
                <bt:String id="Contoso.TaskpaneButton.Label" DefaultValue="Show Taskpane" />
                <bt:String id="Contoso.Group1Label" DefaultValue="Commands Group" />
                <bt:String id="Contoso.GetStarted.Title" DefaultValue="Get started with your sample add-in!" />
            </bt:ShortStrings>
            <bt:LongStrings>
                <bt:String id="Contoso.TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane" />
                <bt:String id="Contoso.GetStarted.Description" DefaultValue="Your sample add-in loaded succesfully. Go to the HOME tab and click the 'Show Taskpane' button to get started." />
            </bt:LongStrings>
        </Resources>
    </VersionOverrides>
    <Requirements>
        <Sets DefaultMinVersion="1.1">
            <Set Name="WordApi" MinVersion="1.3"/>
            <Set Name="DialogApi"/>
            <Set Name="ImageCoercion"/>
        </Sets>
    </Requirements>
</OfficeApp>

方案中包含元素的顺序。它失败了,因为您以错误的顺序添加了 Requirements。您需要将 Requirements 部分放在 DefaultSettings 部分之前:

<Hosts>
    <Host Name="Workbook" />
</Hosts>
<Requirements>
    <Sets DefaultMinVersion="1.1">
        <Set Name="WordApi" MinVersion="1.3"/>
        <Set Name="DialogApi"/>
        <Set Name="ImageCoercion"/>
    </Sets>
</Requirements>    
<DefaultSettings>
    <SourceLocation DefaultValue="https://localhost:3000/index.html" />
</DefaultSettings>