Excel 附加组件、清单、共享 JavaScript 运行时,无法定义 <Runtimes> 元素

Excel add-on, manifest, shared JavaScript runtime, can`t define <Runtimes> element

我们正在开发一个 Excel 附加组件并试图实现它 'working long'。现在它在其选项卡打开时开始工作,但我们希望在加载文档时 运行 它然后保持加载项工作。 据我了解,这种方法可以帮助: https://docs.microsoft.com/en-us/office/dev/add-ins/develop/configure-your-add-in-to-use-a-shared-runtime

bu 当我开始定义清单时:

...
<Hosts>
      <Host xsi:type="Workbook">
        <Runtimes>
          <Runtime resid="KI.Taskpane.UrlMain" lifetime="long" />
        </Runtimes>
        
        <DesktopFormFactor>
        ...

然后 'publish' 清单 - MS VS 2017 报告错误:

命名空间 'http://schemas.microsoft.com/office/taskpaneappversionoverrides' 中的元素 'Host' 在命名空间 'http://schemas.microsoft.com/office/taskpaneappversionoverrides' 中具有无效的子元素 'Runtimes'。

预期的可能元素列表:'DesktopFormFactor' 命名空间 'http://schemas.microsoft.com/office/taskpaneappversionoverrides'。

我该如何解决? 感谢您的建议。

PS: 这是关于 'runtimes' 的 MS Doc https://docs.microsoft.com/ru-ru/office/dev/add-ins/reference/manifest/runtimes

我的 VS 模板似乎太旧了。这是找到的解决方案(但提交的文件需要小 XML 修复)

https://github.com/OfficeDev/office-js-docs-pr/issues/2392

找到文件TaskPaneAppVersionOverridesV1_0.xsd

对我来说是 --> C:\Program Files (x86)\Microsoft Visual Studio17\Community\Xml\Schemas33\

替换为这个文件 --> https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-owemxml/82e93ec5-de22-42a8-86e3-353c8336aa40

 <xs:schema id="TaskPaneAppVersionOverrides" elementFormDefault="qualified" version="1.0" targetNamespace="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:import schemaLocation="OfficeAppBasicTypesV1_0.xsd" namespace="http://schemas.microsoft.com/office/officeappbasictypes/1.0"/>
   <xs:complexType name="ShowTaskpane">
     <xs:complexContent>
       <xs:extension base="Action">
         <xs:sequence>
           <xs:element name="TaskpaneId" type="bt:ShortString" minOccurs="0" maxOccurs="1"/>
           <xs:element name="SourceLocation" type="bt:URLResourceReference" minOccurs="1" maxOccurs="1"/>
           <xs:element name="Title" type="bt:ShortResourceReference" minOccurs="0" maxOccurs="1"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="ExecuteFunction">
     <xs:complexContent>
       <xs:extension base="Action">
         <xs:sequence>
           <xs:element name="FunctionName" type="bt:LongString" minOccurs="1" maxOccurs="1"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="Action" abstract="true"/>
   <xs:complexType name="Supertip">
     <xs:sequence>
       <xs:element name="Title" type="bt:ShortResourceReference" minOccurs="1" maxOccurs="1"/>
       <xs:element name="Description" type="bt:LongResourceReference" minOccurs="1" maxOccurs="1"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="UIControl" abstract="true">
     <xs:sequence>
       <xs:element name="OverriddenByRibbonApi" type="xs:boolean" minOccurs="0" maxOccurs="1" default="false"/>
       <xs:element name="Label" type="bt:ShortResourceReference" minOccurs="1" maxOccurs="1"/>
       <xs:element name="Supertip" type="Supertip" minOccurs="1" maxOccurs="1"/>
     </xs:sequence>
     <xs:attribute name="id" type="bt:ShortString" use="required"/>
   </xs:complexType>
   <xs:complexType name="UIControlWithIcon" abstract="true">
     <xs:complexContent>
       <xs:extension base="UIControl">
         <xs:sequence>
           <xs:element name="Icon" type="bt:IconList" minOccurs="1" maxOccurs="1"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="UIControlWithOptionalIcon" abstract="true">
     <xs:complexContent>
       <xs:extension base="UIControl">
         <xs:sequence>
           <xs:element name="Icon" type="bt:IconList" minOccurs="0" maxOccurs="1"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="Button">
     <xs:complexContent>
       <xs:extension base="UIControlWithIcon">
         <xs:sequence>
           <xs:element name="Action" type="Action" minOccurs="1" maxOccurs="1"/>
           <xs:element name="Enabled" type="xs:boolean" minOccurs="0" maxOccurs="1" default="true"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="MenuItem">
     <xs:complexContent>
       <xs:extension base="UIControlWithOptionalIcon">
         <xs:sequence>
           <xs:element name="Action" type="Action" minOccurs="1" maxOccurs="1"/>
           <xs:element name="Enabled" type="xs:boolean" minOccurs="0" maxOccurs="1" default="true"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="MenuItems">
     <xs:sequence>
       <xs:element name="Item" type="MenuItem" minOccurs="1" maxOccurs="unbounded"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="Menu">
     <xs:complexContent>
       <xs:extension base="UIControlWithIcon">
         <xs:sequence>
           <xs:element name="Items" type="MenuItems" minOccurs="1" maxOccurs="1"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="Group">
     <xs:sequence>
       <xs:element name="OverriddenByRibbonApi" type="xs:boolean" minOccurs="0" maxOccurs="1" default="false"/>
       <xs:element name="Label" type="bt:ShortResourceReference" minOccurs="1" maxOccurs="1"/>
       <xs:element name="Icon" type="bt:IconList" minOccurs="1" maxOccurs="1"/>
       <xs:choice minOccurs="1" maxOccurs="unbounded">
         <xs:element name="Control" type="UIControl"/>
         <xs:element name="OfficeControl" type="OfficeControl"/>
       </xs:choice>
     </xs:sequence>
     <xs:attribute name="id" type="bt:ShortString" use="required"/>
   </xs:complexType>
   <xs:complexType name="Tab" abstract="true">
     <xs:attribute name="id" type="bt:ShortString" use="required"/>
   </xs:complexType>
   <xs:complexType name="OfficeMenu">
     <xs:sequence>
       <xs:element name="Control" type="UIControl" minOccurs="1" maxOccurs="unbounded"/>
     </xs:sequence>
     <xs:attribute name="id" type="bt:ShortString" use="required"/>
   </xs:complexType>
   <xs:complexType name="OfficeTab">
     <xs:complexContent>
       <xs:extension base="Tab">
         <xs:sequence>
           <xs:element name="Group" type="Group" minOccurs="1" maxOccurs="unbounded"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="CustomTab">
     <xs:complexContent>
       <xs:extension base="Tab">
         <xs:sequence>
           <xs:choice minOccurs="1" maxOccurs="unbounded">
             <xs:element name="Group" type="Group"/>
             <xs:element name="OfficeGroup" type="OfficeGroup"/>
           </xs:choice>
           <xs:element name="Label" type="bt:ShortResourceReference" minOccurs="1" maxOccurs="1"/>
           <xs:choice minOccurs="0" maxOccurs="1">
             <xs:element name="InsertBefore" type="bt:ShortString"/>
             <xs:element name="InsertAfter" type="bt:ShortString"/>
           </xs:choice>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="OfficeControl">
     <xs:attribute name="id" type="bt:ShortString" use="required"/>
   </xs:complexType>
   <xs:complexType name="OfficeGroup">
     <xs:attribute name="id" type="bt:ShortString" use="required"/>
   </xs:complexType>
   <xs:complexType name="Script">
     <xs:sequence>
       <xs:element name="SourceLocation" type="bt:URLResourceReference" minOccurs="1" maxOccurs="1"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="Page">
     <xs:sequence>
       <xs:element name="SourceLocation" type="bt:URLResourceReference" minOccurs="1" maxOccurs="1"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="Metadata">
     <xs:sequence>
       <xs:element name="SourceLocation" type="bt:URLResourceReference" minOccurs="1" maxOccurs="1"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="ExtensionPoint" abstract="true"/>
   <xs:complexType name="CommandSurfaceExtensionPoint" abstract="true">
     <xs:complexContent>
       <xs:extension base="ExtensionPoint">
         <xs:sequence>
           <xs:element name="OfficeTab" type="OfficeTab" minOccurs="0" maxOccurs="unbounded"/>
           <xs:element name="CustomTab" type="CustomTab" minOccurs="0" maxOccurs="unbounded"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="PrimaryCommandSurface">
     <xs:complexContent>
       <xs:extension base="CommandSurfaceExtensionPoint"/>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="ContextMenu">
     <xs:complexContent>
       <xs:extension base="ExtensionPoint">
         <xs:sequence>
           <xs:element name="OfficeMenu" type="OfficeMenu" minOccurs="1" maxOccurs="unbounded"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="CustomFunctions">
     <xs:complexContent>
       <xs:extension base="ExtensionPoint">
         <xs:sequence>
           <xs:element name="Script" type="Script" minOccurs="1" maxOccurs="1"/>
           <xs:element name="Page" type="Page" minOccurs="1" maxOccurs="1"/>
           <xs:element name="Metadata" type="Metadata" minOccurs="1" maxOccurs="1"/>
           <xs:element name="Namespace" type="bt:ShortResourceReference" minOccurs="0" maxOccurs="1"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="GetStarted">
     <xs:sequence>
       <xs:element name="Title" type="bt:ShortResourceReference" minOccurs="1" maxOccurs="1"/>
       <xs:element name="Description" type="bt:LongResourceReference" minOccurs="1" maxOccurs="1"/>
       <xs:element name="LearnMoreUrl" type="bt:URLResourceReference" minOccurs="1" maxOccurs="1"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="FormFactor">
     <xs:sequence>
       <xs:element name="GetStarted" type="GetStarted" minOccurs="0" maxOccurs="1"/>
       <xs:element name="FunctionFile" type="bt:URLResourceReference" minOccurs="0" maxOccurs="1"/>
       <xs:element name="ExtensionPoint" type="ExtensionPoint" minOccurs="1" maxOccurs="unbounded"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="AllFormFactors">
     <xs:sequence>
       <xs:element name="ExtensionPoint" type="CustomFunctions" minOccurs="0" maxOccurs="1"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="RuntimeOverride">
     <xs:attribute name="resid" type="bt:ShortString" use="required"/>
     <xs:attribute name="type" type="bt:ShortString" use="required"/>
   </xs:complexType>
   <xs:complexType name="Runtime">
     <xs:sequence>
       <xs:element name="Override" type="RuntimeOverride" minOccurs="0" maxOccurs="unbounded"/>
     </xs:sequence>
     <xs:attribute name="resid" type="bt:ShortString" use="required"/>
     <xs:attribute name="lifetime" type="bt:ShortString" use="optional"/>
   </xs:complexType>
   <xs:complexType name="Runtimes">
     <xs:sequence minOccurs="1" maxOccurs="unbounded">
       <xs:element name="Runtime" type="Runtime"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="Host" abstract="true">
     <xs:sequence>
       <xs:element name="Runtimes" type="Runtimes" minOccurs="0" maxOccurs="1"/>
       <xs:element name="AllFormFactors" type="AllFormFactors" minOccurs="0" maxOccurs="1"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="Workbook">
     <xs:complexContent>
       <xs:extension base="Host">
         <xs:sequence>
           <xs:element name="DesktopFormFactor" type="FormFactor" minOccurs="0" maxOccurs="1"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="Document">
     <xs:complexContent>
       <xs:extension base="Host">
         <xs:sequence>
           <xs:element name="DesktopFormFactor" type="FormFactor" minOccurs="0" maxOccurs="1"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="Notebook">
     <xs:complexContent>
       <xs:extension base="Host">
         <xs:sequence>
           <xs:element name="DesktopFormFactor" type="FormFactor" minOccurs="0" maxOccurs="1"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="Presentation">
     <xs:complexContent>
       <xs:extension base="Host">
         <xs:sequence>
           <xs:element name="DesktopFormFactor" type="FormFactor" minOccurs="0" maxOccurs="1"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="Hosts">
     <xs:sequence minOccurs="1" maxOccurs="unbounded">
       <xs:element name="Host" type="Host"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="WebApplicationScopes">
     <xs:sequence minOccurs="1" maxOccurs="unbounded">
       <xs:element name="Scope" type="bt:LongString"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="WebApplicationInfo">
     <xs:sequence minOccurs="1" maxOccurs="1">
       <xs:element name="Id" type="bt:UUID" minOccurs="1" maxOccurs="1"/>
       <xs:element name="Resource" type="bt:LongString" minOccurs="1" maxOccurs="1"/>
       <xs:element name="Scopes" type="WebApplicationScopes" minOccurs="1" maxOccurs="1"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="EquivalentAddins">
     <xs:sequence minOccurs="1" maxOccurs="unbounded">
       <xs:element name="EquivalentAddin" type="EquivalentAddin"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="EquivalentAddin">
     <xs:sequence minOccurs="1" maxOccurs="1">
       <xs:element name="ProgId" type="bt:LongString" minOccurs="0" maxOccurs="1"/>
       <xs:element name="DisplayName" type="bt:LongString" minOccurs="0" maxOccurs="1"/>
       <xs:element name="FileName" type="bt:LongString" minOccurs="0" maxOccurs="1"/>
       <xs:element name="Type" type="bt:ShortString" minOccurs="1" maxOccurs="1"/>
     </xs:sequence>
   </xs:complexType>
   <xs:complexType name="VersionOverridesV1_0">
     <xs:sequence>
       <xs:element name="Description" type="bt:LongResourceReference" minOccurs="0" maxOccurs="1"/>
       <xs:element name="Requirements" type="bt:Requirements" minOccurs="0" maxOccurs="1"/>
       <xs:element name="Hosts" type="Hosts" minOccurs="0" maxOccurs="1"/>
       <xs:element name="Resources" type="bt:Resources" minOccurs="0" maxOccurs="1"/>
       <xs:element name="WebApplicationInfo" type="WebApplicationInfo" minOccurs="0" maxOccurs="1"/>
       <xs:element name="EquivalentAddins" type="EquivalentAddins" minOccurs="0" maxOccurs="1"/>
       <xs:any id="VersionOverrides" minOccurs="0" maxOccurs="1" namespace="http://schemas.microsoft.com/office/taskpaneappversionoverrides/1.1" processContents="lax"/>
     </xs:sequence>
   </xs:complexType>
   <xs:element name="VersionOverrides" type="VersionOverridesV1_0"/>
 </xs:schema>