从Office旁加载外接程序以进行测试Sideload Office Add-ins for testing from a network share

可以通过将 Office清单发布到网络文件共享Windows在 Office 客户端中测试 (外接程序,具体) 。You can test an Office Add-in in an Office client that is on Windows by publishing the manifest to a network file share (instructions below). 此部署选项用于完成对 localhost 的开发和测试,并且希望从非本地服务器或云帐户测试外接程序。This deployment option is intended to be used when you have completed development and testing on a localhost and want to test the add-in from a non-local server or cloud account.

重要

生产加载项不支持通过网络共享进行部署。此方法具有以下限制:Deployment by network share is not supported for production add-ins. This method has the following limitations:

  • 加载项只能安装在Windows计算机上。The add-in can only be installed on Windows computers.
  • 如果加载项的新版本更改功能区,每个用户必须重新安装加载项。If a new version of an add-in changes the ribbon, each user will have to reinstall the add-in.

备注

如果你的外接程序项目是使用外接程序的 Yeoman 生成器的足够使用的版本,运行 npm start 时将自动在 Office 桌面客户端中旁加载外接程序。If your add-in project was created with a sufficiently recent version of the Yeoman generator for Office Add-ins, the add-in will automatically sideload in the Office desktop client when you run npm start.

本文仅适用于测试 Word、Excel、PowerPoint 和 Project 加载项,仅适用于 Windows。This article applies only to testing Word, Excel, PowerPoint, and Project add-ins and only on Windows. 如果要在其他平台上进行测试或要测试 Outlook 加载项,请参阅以下主题之一以旁加载你的加载项:If you want to test on another platform or want to test an Outlook add-in, see one of the following topics to sideload your add-in:

下面的视频逐步展示了如何使用共享文件夹目录在 Office 网页版或桌面上旁加载加载项。The following video walks you through the process of sideloading your add-in in Office on the web or desktop using a shared folder catalog.

共享文件夹Share a folder

  1. 在想要托管外接程序的 Windows 计算机上,转到你想用作共享文件夹目录的文件夹的父文件夹或驱动器号。In File Explorer on the Windows computer where you want to host your add-in, go to the parent folder, or drive letter, of the folder you want to use as your shared folder catalog.

  2. 打开要用作共享文件夹目录的文件夹的上下文菜单(右键单击该文件夹),然后选择“属性”。Open the context menu for the folder you want to use as your shared folder catalog (right-click the folder) and choose Properties.

  3. 在“属性”对话框窗口中,打开“共享”选项卡,然后选择“共享”按钮。Within the Properties dialog window, open the Sharing tab and then choose the Share button.

    已突出显示“共享”选项卡和“共享”按钮的文件夹“属性”对话框

  4. 网络访问 对话框窗口中,添加你自己以及要与其共享加载项的任何其他用户和/或组。Within the Network access dialog window, add yourself and any other users and/or groups with whom you want to share your add-in. 你至少需要对该文件夹的 读/写 权限。You will need at least Read/Write permission to the folder. 选择要与其共享的人员后,请选择“共享”按钮。After you have finished choosing people to share with, choose the Share button.

  5. 当你看到确认 你的文件夹已共享 的消息时,请记下紧跟文件夹名称显示的完整网络路径。When you see confirmation that Your folder is shared, make note of the full network path that's displayed immediately following the folder name. (当你 将共享文件夹指定为受信任的目录时,你需要将此值输入为 目录UR,如本文下一节所述。)选择“完成”按钮以关闭“网络访问”对话框窗口。(You will need to enter this value as the Catalog Url when you specify the shared folder as a trusted catalog, as described in the next section of this article.) Choose the Done button to close the Network access dialog window.

    已突出显示共享路径的“网络访问”对话框

  6. 选择“关闭”按钮以关闭“属性”对话框窗口。Choose the Close button to close the Properties dialog window.

将共享文件夹指定为受信任的目录Specify the shared folder as a trusted catalog

手动配置信任Configure the trust manually

  1. 在 Excel、Word、PowerPoint 或 Project 中打开一个新的文档。Open a new document in Excel, Word, PowerPoint, or Project.

  2. 选择“文件”选项卡,然后选择“选项”。Choose the File tab, and then choose Options.

  3. 选择“信任中心”,然后选择“信任中心设置”按钮。Choose Trust Center, and then choose the Trust Center Settings button.

  4. 选择“受信任的加载项目录”。Choose Trusted Add-in Catalogs.

  5. 在“目录 Url”框中,输入你之前 共享的文件夹的完整网络路径。In the Catalog Url box, enter the full network path to the folder that you shared previously. 如果在共享文件夹时未能记下文件夹的完整网络路径,则可以从文件夹的“属性”对话框窗口中获取它,如以下屏幕截图所示。If you failed to note the folder's full network path when you shared the folder, you can get it from the folder's Properties dialog window, as shown in the following screenshot.

    已突出显示“共享”选项卡和网络路径的文件夹“属性”对话框

  6. 在“目录 Url”框中输入文件夹的完整网络路径后,选择“添加目录”按钮。After you've entered the full network path of the folder into the Catalog Url box, choose the Add catalog button.

  7. 选中新添加项目的“在菜单中显示”复选框,然后选择“确定”按钮以关闭“信任中心”对话框窗口。Select the Show in Menu check box for the newly-added item, and then choose the OK button to close the Trust Center dialog window.

    已选择目录的“信任中心”对话框

  8. 选择" 确定" 按钮以关闭 "选项 "对话框窗口。Choose the OK button to close the Options dialog window.

  9. 关闭并重新打开 Office 应用程序,以使更改生效。Close and reopen the Office application so your changes will take effect.

使用注册表脚本配置信任Configure the trust with a Registry script

  1. 在文本编辑器中,创建名为 TrustNetworkShareCatalog.reg 的文件。In a text editor, create a file named TrustNetworkShareCatalog.reg.

  2. 在文件中添加以下内容:Add the following content to the file:

    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\WEF\TrustedCatalogs\{-random-GUID-here-}]
    "Id"="{-random-GUID-here-}"
    "Url"="\\\\-share-\\-folder-"
    "Flags"=dword:00000001
    
  3. 在众多在线 GUID 生成工具中选用一个(例如 GUID 生成器)来生成一个随机 GUID,并在 TrustNetworkShareCatalog.reg 文件中,将 两个位置 的“-random-GUID-here-”字符串都替换为 GUID。Use one of the many online GUID generation tools, such as GUID Generator, to generate a random GUID, and within the TrustNetworkShareCatalog.reg file, replace the string "-random-GUID-here-" in both places with the GUID. (应保留右侧 {} 符号)。(The enclosing {} symbols should remain.)

  4. Url 值替换为你之前共享的文件夹的完整网络路径。Replace the Url value with the full network path to the folder that you shared previously. (请注意,URL 中的所有 \ 字符都必须成双出现。)如果在共享文件夹时未能记下文件夹的完整网络路径,则可从文件夹的“属性”对话框窗口中获取它,如以下屏幕截图所示。(Note that any \ characters in the URL must be doubled.) If you failed to note the folder's full network path when you shared the folder, you can get it from the folder's Properties dialog window, as shown in the following screenshot.

    已突出显示“共享”选项卡和网络路径的文件夹“属性”对话框

  5. 文件现应如下所示。The file should now look like the following. 将其保存。Save it.

    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\WEF\TrustedCatalogs\{01234567-89ab-cedf-0123-456789abcedf}]
    "Id"="{01234567-89ab-cedf-0123-456789abcedf}"
    "Url"="\\\\TestServer\\OfficeAddinManifests"
    "Flags"=dword:00000001
    
  6. 关闭 所有 Office 应用程序。Close all Office applications.

  7. 如同对任何可执行文件操作一样运行 TrustNetworkShareCatalog.reg,例如双击它。Run the TrustNetworkShareCatalog.reg just as you would any executable, such as double-clicking it.

旁加载加载项Sideload your add-in

  1. 放入在共享文件夹目录中进行测试的所有加载项的清单 XML 文件。Put the manifest XML file of any add-in that you are testing in the shared folder catalog. 请务必将 Web 应用程序本身部署到 Web 服务器。Note that you deploy the web application itself to a web server. 务必在清单文件的 SourceLocation 元素中指定 URL。Be sure to specify the URL in the SourceLocation element of the manifest file.

    重要

    虽然在所有外接程序方案中并不严格要求,但强烈建议您对外接程序使用 HTTPS 终结点。不受 SSL 保护的外接程序(HTTPS)在使用过程中生成不安全的内容警告和错误。如果您计划在 web 上的 Office 中运行外接程序或将外接程序发布到 AppSource,则它必须采用 SSL 保护。如果你的加载项访问外部数据和服务,应进行 SSL 保护,以保护传输中的数据。自签名证书可用于开发和测试,只要证书在本地计算机上受信任。While not strictly required in all add-in scenarios, using an HTTPS endpoint for your add-in is strongly recommended. Add-ins that are not SSL-secured (HTTPS) generate unsecure content warnings and errors during use. If you plan to run your add-in in Office on the web or publish your add-in to AppSource, it must be SSL-secured. If your add-in accesses external data and services, it should be SSL-secured to protect data in transit. Self-signed certificates can be used for development and testing, so long as the certificate is trusted on the local machine.

    备注

    对于Visual Studio,请使用 文件夹中的项目所构建的 {projectfolder}\bin\Debug\OfficeAppManifests 清单。For Visual Studio projects, use the manifest built by the project in the {projectfolder}\bin\Debug\OfficeAppManifests folder.

  2. 在 Excel、Word 或 PowerPoint 中,选择功能区上“插入”选项卡中的“我的加载项”。In Excel, Word, or PowerPoint, select My Add-ins on the Insert tab of the ribbon. 在 Project 中,选择功能区“Project”选项卡上的“我的加载项”。In Project, select My Add-ins on the Project tab of the ribbon.

  3. 在“Office 外接程序”对话框的顶部,选择“共享文件夹”。Choose SHARED FOLDER at the top of the Office Add-ins dialog box.

  4. 选择加载项的名称,然后选择“添加”以插入加载项。Select the name of the add-in and choose Add to insert the add-in.

删除旁加载的外接程序Remove a sideloaded add-in

可以通过清除计算机上以前旁加载的Office缓存来删除。You can remove a previously sideloaded add-in by clearing the Office cache on your computer. 有关在缓存上清除Windows的详细信息,请参阅清除缓存Office。Details on how to clear the cache on Windows can be found in the article Clear the Office cache.

另请参阅See also