您如何打包VSTO Word加载项以使用WIX进行部署(到Office 32位)? [英] How do you package a VSTO Word addin for deployment (to Office 32 bit) using WIX?

查看:129
本文介绍了您如何打包VSTO Word加载项以使用WIX进行部署(到Office 32位)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS 2017 Pro中开发了VSTO Word add in.工作正常,可以部署了.但是,我找不到打包我的VSTO Word add in以便在我的开发机器以外的机器上使用的工作程序.对于任何特定的计算机,我需要将其部署一次,并将其提供给任何可能使用其帐户登录的用户.

I developed a VSTO Word add in in VS 2017 Pro. Works fine, ready to deploy. However, I cannot find a working procedure for packaging my VSTO Word add in for use on machines other than my development machine. For any particular machine , I need to deploy it once and have it available for any user who may login using their account.

首先遇到

First came across this, but it involves using InstallShield Limited Edition which, apparently is no longer available for VS 2017.

尝试 ,但是它的一些步骤似乎缺少了一部分,或者说做x"而没有解释如何做.

Tried this but it a few of its steps seem to be missing parts or say "do x" without explaining how.

尝试了'InnoSetup'和'bovendor/VstoAddinInstaller',但是遵循'bovendor'过程会导致'Innosetup'编译器抛出错误(bovender指示的节缺少必需的元素).无法收到Bovendor的回复.

Tried 'InnoSetup' and the 'bovendor/VstoAddinInstaller', but following the 'bovendor' procedure results in the 'Innosetup' compiler throwing an error (a bovender-dictated stanza is missing a required element). Can't get a response from bovendor.

搜索了Microsoft文档,但找不到过程.谁能提供打包VSTO Word加载项以进行部署的过程?

Searched Microsoft docs and just can't find a procedure. Can anyone provide the procedure for packaging a VSTO Word add in for deployment?

更新 使用WiX工具集成功打包并部署了我的加载项.请在下面查看我的答案

Update Successfully packaged and deployed my add-in using the WiX tool set. See my answer below

推荐答案

更新(11/26/2019):如果您的设置使用64位Office,请参阅

Update (11/26/2019): If your setup uses 64-bit Office, see How do you package a VSTO Word addin for deployment to a 64-bit Windows 10 machine running Microsoft Office 64 bit using WIX?

使用WiX工具集成功打包并部署了add-in

Successfully packaged and deployed my add-in using the WiX tool set

信用:我使用我在开发机(64位)上使用Visual Studio Pro 2017.NET 4.6.1C#来实现我的VSTO Word加载项.

I used Visual Studio Pro 2017, .NET 4.6.1, and C# on my development machine (64-bit) to implement my VSTO Word add-in.

我的要求是将add-in一次部署到64位生产计算机(即Citrix虚拟桌面主映像),以便任何登录到生产计算机(即登录到虚拟机)的用户都可以使用.基于主映像的桌面).主映像上安装了32位版本的Word 2013.

My requirement is to deploy the add-in once to a 64-bit production machine (i.e., a Citrix virtual desktop master image) so it's available to any user who logs onto the production machine (i.e., logs on to a virtual desktop based on the master image). The 32-bit version of Word 2013 is installed on the master image.

据我了解,这意味着加载项"必须安装在"C:\ Program Files(x86)"下,原因有两个:

As I understand it, this means the 'add-in' has to be installed under 'C:\Program Files (x86)' for two reasons:

  1. 因此所有用户都可以访问该加载项,并且
  2. (x86)下的版本,因为它是Word的32位版本.

此外,由于所有用户都需要访问add-in,因此所需的VSTO注册表项设置位于根HKLM(而非HKCU)下.本质上,此所有用户"设置与一个用户" Click-Once设置相反.毫无疑问,我处于一个未连接到互联网的飞地中.因此,我使用的所有软件都从其他位置下载,然后带入安全区域并本地安装.

Also, because all users need to access the add-in, the required VSTO registry key settings go under the root HKLM (and not HKCU). Essentially, this 'all users' setup is the opposite of the 'one user' Click-Once setup. Apropos of nothing, I'm in an enclave that is not connected to the Internet. So, all software I use is downloaded elsewhere, and then carried into the enclave and installed locally.

我的VSTO单词加载项(即,在C:\....\Visual Studio 2017\Projects\FooAddIn\FooAddIn\bin\Release中)的发布文件是:

The release files for my VSTO word add-in (i.e, in C:\....\Visual Studio 2017\Projects\FooAddIn\FooAddIn\bin\Release) are:

  • FooAddIn.dll
  • FooAddIn.dll.manifest
  • FooAddIn.vsto
  • Microsoft.Office.Tools.Common.v4.0.Utilities.dll

我做什么

使用VS 2017打开我的add-in项目FooAddIn,在Solution Explorer中,右键单击顶部的Solution节点,然后单击Add -> New Project.

Opened my add-in project FooAddIn using VS 2017 and in Solution Explorer, right-mouse clicked on the top-line Solution node and clicked Add -> New Project.

Add New Project对话框中,单击WiX Toolset下的v3,然后单击Setup Project for WiX v3.我将新项目命名为FooAddInSetup. Visual Studio Solution Explorer显示Solution FooAddIn (2 projects),项目FooAddIn和项目FooAddInSetup.

In the Add New Project dialog, clicked on v3 under WiX Toolset and then clicked on Setup Project for WiX v3. I named the new project FooAddInSetup. Visual Studio Solution Explorer shows Solution FooAddIn (2 projects), project FooAddIn, and project FooAddInSetup.

FooAddInSetup -> References下,添加了对C:\Program Files (x86)\WiX Toolset v3.11\bin\WixNetFxExtension.dllC:\Program Files (x86)\WiX Toolset v3.11\bin\WixUIExtension.dll的引用(Product.wxs文件的元素需要这些引用来构建安装程序).

Under FooAddInSetup -> References, added references to C:\Program Files (x86)\WiX Toolset v3.11\bin\WixNetFxExtension.dll and C:\Program Files (x86)\WiX Toolset v3.11\bin\WixUIExtension.dll (These are needed by elements of the Product.wxs file to build the installer).

配置的VS还可以生成安装程序:在VS中,单击生成"->配置管理器".在配置管理器"对话框中,选中FooAddInSetup的Build复选框.

Configured VS to also build the setup program: In VS, click on Build -> Configuration Manager. In the Configuration Manager dialog, checked the Build check box for FooAddInSetup.

创建了EULA.rtf(我说这是免许可证的软件")并将其放在C:.... \ Visual Studio 2017 \ Projects \ FooAddIn \ FooAddInSetup

Created EULA.rtf (mine says "This is license-free software") and placed it in C:....\Visual Studio 2017\Projects\FooAddIn\FooAddInSetup

为我的VSTO发行文件的位置路径创建了预处理程序变量:在解决方案资源管理器中,右键单击FooAddInSetup -> Properties.在FooAddInSetup选项卡上,单击生成".在General部分中,单击Define 'Debug' preprocessor variable.在Define preprocessor variables:文本框中,输入AddinFiles=..\FooAddIn\bin\$(Configuration)\

Created a preprocessor variable for the path to the location of my VSTO release files: In Solution Explorer, right mouse clicked FooAddInSetup -> Properties. On the FooAddInSetup tab, Clicked on 'Build'. In the General section, clicked Define 'Debug' preprocessor variable. In the Define preprocessor variables: textbox, entered AddinFiles=..\FooAddIn\bin\$(Configuration)\

为我的add-in填充样板WiX Product.wxs文件,如下所示,在 Product.wxs文件

Populated the boilerplate WiX Product.wxs file for my add-in as shown below under Product.wxs file

注意:在wxs文件中,我修改了Condition元素中的Visual Studio 2010 Tools for Office Runtime超链接-Pieter示例中的那个已死.

Note: In the wxs file, I modified the Visual Studio 2010 Tools for Office Runtime hyperlink in the Condition element - the one in Pieter's example is dead.

我将解决方案配置设置为Release并构建了解决方案.

I set the Solution Configuration to Release and built the solution.

FooAddInSetup.msi从我的开发机上的...\FooAddInSetup\bin\release复制到生产机(VDI主站)上,并以管理员身份运行安装程序.

Copied FooAddInSetup.msi from ...\FooAddInSetup\bin\release on my dev machine to my production machine (the VDI master) and ran the setup program as admin.

结果

  1. 与我在wxs文件中声明的注册表设置无关,我的注册表项是在HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\Word\AddIns\LesCaveatAddIn中创建的,即,它们按预期进入HKLM,但进入了\Software\Wow6432Node\Microsoft.....而不是<我在wxs文件中编码的c60>.我认为这是因为我的生产机器是64位机器.

  1. Without regard to the registry settings I asserted in the wxs file, my registry keys were created in HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\Word\AddIns\LesCaveatAddIn, i.e., they went into HKLM as expected, but they went into \Software\Wow6432Node\Microsoft..... instead of \Software\Microsoft.... as I coded in the wxs file. I assume this is because my production machine is a 64-bit machine.

按预期,该加载项本身已安装在c:\ program文件(x86)下

As expected, the add-in itself was installed under c:\program files (x86)

启动Word,并按预期加载了加载项

Brought up Word, and the add-in was loaded as expected

Product.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>

这篇关于您如何打包VSTO Word加载项以使用WIX进行部署(到Office 32位)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆