在 Office 加载项清单中指定 ~remoteAppUrl 的值

Specify value for ~remoteAppUrl in an Office add-in manifest

我正在使用 new framework 为 Outlook 编写一个加载项。项目模板中的清单使用 ~remoteAppUrl 来表示 Web 文件的位置。它在开发过程中运行良好,但要发布到 Office Store,我需要在那里制作 URL。如果我将生产 URL 保存到清单中,则在调试期间会使用生产服务器,因此不会显示本地更改。

文档提到 Visual Studio 在调试期间填写此值:

Next, Visual Studio does the following:
1. Modifies the SourceLocation element of the XML manifest file by replacing the ~remoteAppUrl token with the fully qualified address of the start page (for example, http://localhost/MyAgave.html).

是否有内置方法让 Visual Studio 在适当的时间填写生产 URL(before/during Office Store 提交),而不中断调试?

编辑:

Visual Studio 不会填写生产 URL,但是您可以复制当前清单并手动将 ~remoteAppUrl 替换为您合适的主机,从而为您提供生产和调试您的加载项版本。

为后人原创

~remoteAppUrl 是文件托管位置的占位符。例如,如果您已将加载项上传到 Azure Web 应用程序,则您的远程应用程序 url 将类似于 myWebApp.azurewebsites.net

是的,有一种内置方法可以让 Visual Studio 将 ~remoteAppUrl 符号引用标记替换为您选择的目标 URL。

  1. 从 Visual Studio,访问加载项的 "Publish..." 选项 项目,然后单击 "Package the add-in" 按钮
  2. 然后您可以在弹出的模态对话框中输入URL
  3. 然后触发构建,将 URL 注入生成的清单 XML 文件
  4. A Windows 资源管理器 window 将方便地打开以显示 生成的文件。

以下方法不是内置的,但也可能有用。

如果您希望在自动构建中使用它,您需要为构建参数 IsPackaging (True) 和 RemoteAppUrl.

指定值

如果你想在标准 Visual Studio 构建中使用它,鉴于 Visual Studio 没有提供指定构建参数的简单方法(请参阅 How to emulate /p msbuild parameter in Visual Studio build?),你将需要编辑你的项目文件来设置相同构建参数的值。 比如像这样:

...
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    ...
    <IsPackaging>True</IsPackaging>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    ...
    <RemoteAppUrl>https://localhost:44300</RemoteAppUrl>
  </PropertyGroup>
  ...  
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    ...
    <RemoteAppUrl>https://your.own.url</RemoteAppUrl>
  </PropertyGroup>
...

我想阐明值的来源以替换 ~remoteAppUrl 参数。加载项 .csproj 文件包含对 WebApp 项目的引用:

<ItemGroup>                                                                     
  <ProjectReference Include="..\OutlookWebAddIn1Web\OutlookWebAddIn1Web.csproj">
    <Project>{57AC33A8-A364-4084-B41F-319C5DBB9FB4}</Project>                   
    <Name>OutlookWebAddIn1Web</Name>                                            
    <Private>True</Private>                                                     
    <RoleType>Web</RoleType>                                                    
    <OutputItemType>SharePointWebProjectOutput</OutputItemType>                 
    <RoleName>OutlookWebAddIn1Web</RoleName>                                    
    <ReferenceOutputAssembly>False</ReferenceOutputAssembly>                    
  </ProjectReference>                                                           
</ItemGroup>    

我认为它从 WebApp .csproj 文件中获取 URL: