ms-word - 如何使用 WIX 打包 VSTO Word 插件以进行部署(到 Office 32 位)?
问题描述
我VSTO
Word
add in
在 VS 2017 Pro 中开发了一个。工作正常,准备部署。但是,我找不到打包我的工作程序以VSTO
Word
add in
在我的开发机器以外的机器上使用。对于任何特定的机器,我需要部署一次,并让任何可能使用他们的帐户登录的用户都可以使用它。
第一次遇到这个,但它涉及使用 InstallShield Limited Edition,它显然不再适用于 VS 2017。
试过这个,但它的一些步骤似乎缺少部分或说“做 x”而不解释如何。
尝试了“InnoSetup”和“bovendor/VstoAddinInstaller”,但遵循“bovendor”过程会导致“Innosetup”编译器抛出错误(bovender-dictated stanza is missing an required element)。无法得到博文多的回应。
搜索Microsoft
文档,只是找不到程序。任何人都可以提供打包 VSTO Word 插件以进行部署的过程吗?
更新 使用 WiX 工具集成功打包并部署了我的加载项。请看下面我的回答
解决方案
更新(2019 年 11 月 26 日):如果您的设置使用 64 位 Office,请参阅如何打包 VSTO Word 插件以部署到使用 WIX 运行 Microsoft Office 64 位的 64 位 Windows 10 计算机?
add-in
使用WiX
工具集成功打包部署my
信用:我在Add-in Express Blog上使用Pieter van der Westhuizen 的示例学到了大部分内容。
我在我的开发机器(64 位)上使用Visual Studio Pro 2017
、.NET 4.6.1
和来实现我的加载项。C#
VSTO
Word
我的要求是将add-in
一次部署到 64 位生产机器(即 Citrix 虚拟桌面主映像),以便任何登录生产机器的用户都可以使用它(即基于主映像登录到虚拟桌面)。32 位版本的 Word 2013 安装在主映像上。
据我了解,这意味着“加载项”必须安装在“C:\Program Files (x86)”下,原因有两个:
- 所以所有用户都可以访问加载项,并且
- 在 (x86) 下,因为它是 Word 的 32 位版本)。
此外,由于所有用户都需要访问add-in
,因此所需的VSTO
注册表项设置位于根目录下HKLM
(而不是HKCU
)。本质上,这种“所有用户”设置与“一个用户”Click-Once
设置相反。顺便说一句,我在一个没有连接到互联网的飞地中。因此,我使用的所有软件都在其他地方下载,然后携带到 enclave 并安装在本地。
VSTO
我的word 插件(即 in )的发布文件C:\....\Visual Studio 2017\Projects\FooAddIn\FooAddIn\bin\Release
是:
- FooAddIn.dll
- FooAddIn.dll.manifest
- FooAddIn.vsto
- Microsoft.Office.Tools.Common.v4.0.Utilities.dll
我做了什么
从http://wixtoolset.org/releases/下载并安装 'WiX' v3.11.1 到我的开发机器上。
从https://marketplace.visualstudio.com/items?itemName=RobMensching.WixToolsetVisualStudio2017Extension下载并安装“Wix Toolset Visual Studio 2017 Extension”到我的开发机器上
使用和打开我的
add-in
项目,鼠标右键单击顶行节点并单击。FooAddIn
VS 2017
Solution Explorer
Solution
Add -> New Project
在
Add New Project
对话框中,单击v3
下方WiX Toolset
,然后单击Setup Project for WiX v3
。我将新项目命名为FooAddInSetup
。Visual StudioSolution Explorer
显示Solution FooAddIn (2 projects)
、项目FooAddIn
和项目FooAddInSetup
。在 下
FooAddInSetup -> References
,添加了对C:\Program Files (x86)\WiX Toolset v3.11\bin\WixNetFxExtension.dll
和的引用C:\Program Files (x86)\WiX Toolset v3.11\bin\WixUIExtension.dll
(Product.wxs 文件的元素需要这些引用来构建安装程序)。配置 VS 以构建安装程序:在 VS 中,单击构建 -> 配置管理器。在“配置管理器”对话框中,选中
Build
FooAddInSetup 的复选框。创建
EULA.rtf
(我说“这是免许可软件”)并将其放在 C:....\Visual Studio 2017\Projects\FooAddIn\FooAddInSetup为我的发布文件位置的路径创建了一个预处理器变量
VSTO
:在解决方案资源管理器中,右键单击FooAddInSetup -> Properties
. 在 FooAddInSetup 选项卡上,单击“构建”。在该General
部分中,单击Define 'Debug' preprocessor variable
。在Define preprocessor variables:
文本框中,输入AddinFiles=..\FooAddIn\bin\$(Configuration)\
填充了我的样板
WiX
Product.wxs
文件,add-in
如下所示在Product.wxs 文件下注意:在
wxs
文件中,我修改了元素中的Visual Studio 2010 Tools for Office Runtime
超链接- Pieter 示例中的超链接已失效。Condition
我将解决方案配置设置为
Release
并构建了解决方案。FooAddInSetup.msi
从我的开发机器上复制...\FooAddInSetup\bin\release
到我的生产机器(VDI 主机)并以管理员身份运行安装程序。
结果
不考虑我在
wxs
文件中声明的注册表设置,我的注册表项是在 中创建的HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\Word\AddIns\LesCaveatAddIn
,即它们按预期进入 HKLM,但它们进入\Software\Wow6432Node\Microsoft.....
而不是像我在文件中\Software\Microsoft....
编码的那样进入。wxs
我认为这是因为我的生产机器是 64 位机器。正如预期的那样,加载项本身安装在 c:\program files (x86) 下
调出 Word,加载项按预期加载
产品.wxs 文件
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<!--
The boilerplate Product.wxs file already contains the minimum amount of elements needed to build a WiX installer.
If the Product element, Id attribute is set to an asterisk (*), WiX will generate a new GUID every time the setup project is compiled (I left it as-is).
Change the Name attribute value and Manufacturer attribute value to values of your choice.
-->
<Product Id="*"
Name="FOO Add-In"
Language="1033"
Version="1.0.0.0"
Manufacturer="Foo Masters"
UpgradeCode="4b35cc09-4780-4644-a7d4-f5901f7a7e45">
<!--Attributes shown are the minimum number needed to build the setup project.-->
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<!-- Verify if VSTO Office Runtime is installed -->
<Property Id="VSTORUNTIMEREDIST">
<RegistrySearch
Id="VSTORuntimeRedist"
Root="HKLM"
Key="SOFTWARE\Microsoft\VSTO Runtime Setup\v4R"
Name="Version"
Type="raw" />
</Property>
<Condition
Message="The Visual Studio 2010 Tools for Office Runtime is not installed.
Please download and install from https://www.microsoft.com/en-us/download/details.aspx?id=48217.">
<![CDATA[Installed OR VSTORUNTIMEREDIST>="10.0.30319"]]>
</Condition>
<!-- Verify if .NET Framework is installed -->
<PropertyRef Id="NETFRAMEWORK40FULL"/>
<Condition Message="This application requires .NET Framework 4.0.">
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
</Condition>
<!--I want one Cab file, so only one Media element is needed. Make sure the EmbedCab attribute value is "yes".-->
<Media Id="1" Cabinet="FooAddin.cab" EmbedCab="yes"/>
<!--Set values for display on setup progeam UI-->
<Feature Id="ProductFeature" Title="FOO Add-In" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="Registry_FriendlyName" />
<ComponentRef Id="Registry_Description" />
<ComponentRef Id="Registry_Manifest" />
<ComponentRef Id="Registry_LoadBehavior" />
</Feature>
<!--Specify that the WiXUI_Minimal UI should be used, i.e, the simplest UI available -->
<UIRef Id="WixUI_Minimal" />
<!--Specify the EULA file to use-->
<WixVariable Id="WixUILicenseRtf" Value="EULA.rtf" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="FooAddin" />
<!-- Add required VSTO registry entries for 32-bit Word -->
<!-- see https://docs.microsoft.com/en-us/visualstudio/vsto/registry-entries-for-vsto-add-ins?view=vs-2019-->
<Component Id="Registry_FriendlyName">
<RegistryValue Id="RegKey_FriendlyName" Root="HKLM"
Key="Software\Microsoft\Office\Word\AddIns\FooAddin"
Name="FriendlyName"
Value="FOO Add-In"
Type="string" KeyPath="yes" />
</Component>
<Component Id="Registry_Description">
<RegistryValue Id="RegKey_Description" Root="HKLM"
Key="Software\Microsoft\Office\Word\AddIns\FooAddin"
Name="Description"
Value="FOO Add-In"
Type="string" KeyPath="yes" />
</Component>
<Component Id="Registry_Manifest">
<RegistryValue Id="RegKey_Manifest" Root="HKLM"
Key="Software\Microsoft\Office\Word\AddIns\FooAddin"
Name="Manifest" Value="[INSTALLFOLDER]FooAddin.vsto|vstolocal"
Type="string" KeyPath="yes" />
</Component>
<Component Id="Registry_LoadBehavior">
<RegistryValue Id="RegKey_LoadBehavior" Root="HKLM"
Key="Software\Microsoft\Office\Word\AddIns\FooAddin"
Name="LoadBehavior" Value="3"
Type="integer" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Fragment>
<Fragment>
<!-- Add refs to the components of the VSTO-->
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="MSOfficeToolsCommon_dll_Component">
<File Id="MSOfficeToolsCommon_dll" KeyPath="yes"
Name="Microsoft.Office.Tools.Common.v4.0.Utilities.dll"
Source="$(var.AddinFiles)"></File>
</Component>
<Component Id="FooAddin_dll_Component" >
<File Id="FooAddin_dll" KeyPath="yes"
Name="FooAddin.dll"
Source="$(var.AddinFiles)" />
</Component>
<Component Id="FooAddin_vsto_Component">
<File Id="FooAddin_vsto" KeyPath="yes"
Name="FooAddin.vsto"
Source="$(var.AddinFiles)"></File>
</Component>
<Component Id="FooAddin_dll_manifest_Component">
<File Id="FooAddin_dll_manifest" KeyPath="yes"
Name="FooAddin.dll.manifest"
Source="$(var.AddinFiles)"></File>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
推荐阅读
- laravel - 在 Laravel 中单击更改页面的一部分
- php - 首先用它的字符串替换变量,然后执行 `if` 检查
- javascript - JQuery 运行双重请求路由
- c# - 值不能为空。参数名称:实例
- eclipse - 配置 Eclipse/PyDev 以使用远程服务器和远程解释器上的项目(解决方法和陷阱)
- angularjs - Intellij 使用 angularjs 检查不需要的警告
- php - 由于 composer.json 在苗条树框架中的致命错误
- vba - 将值从工作表“数据存储”A1 复制到工作表“1”D4...“数据存储”A2 到工作表“2”,依此类推
- tensorflow - 有没有人找到让 Tensorboard 受密码保护的方法?
- java - 将照片上传到 Google Photos API 不返回上传令牌