首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何使用WIX打包VSTO Word插件以进行部署(到Office 32位)?

如何使用WIX打包VSTO Word插件以进行部署(到Office 32位)?
EN

Stack Overflow用户
提问于 2019-04-24 00:22:24
回答 1查看 3.5K关注 0票数 8

我在VS 2017专业版中开发了一个VSTO Word add in。运行良好,随时可以部署。但是,我找不到打包我的VSTO Word add in以便在我的开发计算机以外的计算机上使用的工作过程。对于任何特定的机器,我需要部署它一次,并使其可供任何使用其帐户登录的用户使用。

第一次遇到this,但它涉及到使用InstallShield限制版,显然在VS 2017中不再可用。

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

尝试了“Innosetup”和“bovendor/VstoAddinInstaller”,但遵循“bovendor”过程会导致“Innosetup”编译器抛出错误(bovender指定的节缺少必需的元素)。无法从bovendor获取响应。

搜索了Microsoft文档,但就是找不到过程。是否有人可以提供打包VSTO Word插件以进行部署的过程?

更新使用WiX工具集成功打包和部署了我的外接程序。请看我下面的答案

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-25 01:59:29

更新(2019年11月26日):如果您的设置使用64位Office,请参阅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

来源:我在Add-in Express Blog上使用Pieter van der Westhuizen's example学习了大部分内容。

我在我的开发计算机(64位)上使用了Visual Studio Pro 2017.NET 4.6.1C#来实现我的VSTO Word外接程序。

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

据我所知,这意味着'add-in‘必须安装在'C:\Program Files (x86)’下,原因有两个:

  1. 以便所有用户都可以访问该加载项,以及
  2. Under (x86),因为它是32位版本的Word)。

此外,因为所有用户都需要访问add-in,所以所需的VSTO注册表项设置位于根HKLM (而不是HKCU)下。从本质上讲,这种“所有用户”的设置与“一个用户”的Click-Once设置相反。无中生有,我在一个没有连接到互联网的飞地上。因此,我使用的所有软件都被下载到其他地方,然后被带到飞地并在本地安装。

我的VSTO word外接程序(即,在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到我的开发机器上。
  • 使用VS 2017https://marketplace.visualstudio.com/items?itemName=RobMensching.WixToolsetVisualStudio2017Extension
  • Opened my add-in项目FooAddIn下载并安装了'Wix Toolset Visual Studio2017 Extension‘到我的开发机器上,在Solution Explorer中,在顶行的Solution节点上单击鼠标右键,然后单击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。在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文件的元素需要它们来构建installer).
  • Configured VS以构建安装程序:在VS中,单击build -> Configuration
  • 。在配置管理器对话框中,选中FooAddInSetup.
  • Created预处理器复选框(我的复选框显示"This is Build -free software"),并将其放在C:....\Visual Studio 2017\Projects\FooAddIn\FooAddInSetup
  • Created一个预处理器变量中,作为我的VSTO发布文件位置的路径:在解决方案资源管理器中,右键单击FooAddInSetup -> Properties。在FooAddInSetup选项卡上,单击“Build”。在General部分中,单击Define 'Debug' preprocessor variable。在Define preprocessor variables:文本框中,输入AddinFiles=..\FooAddIn\bin\$(Configuration)\
  • 为我的Product.wxs填充样板add-in文件,如下所示,在Product.wxs Product.wxs文件中,我修改了<add-in>D91元素中的<>D90超链接-Pieter示例中的超链接已失效。
  • 我将解决方案配置设置为Release,并构建了解决方案。
  • FooAddInSetup.msi从我的开发机器上的...\FooAddInSetup\bin\release复制到我的生产机器( VDI ),并以管理员身份运行安装程序。

结果

  1. 不考虑我在wxs文件中断言的注册表设置,我的注册表项是在HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\Word\AddIns\LesCaveatAddIn中创建的,即它们如预期的那样进入HKLM,但它们进入\Software\Wow6432Node\Microsoft.....而不是我在wxs文件中编码的\Software\Microsoft....。我假设这是因为我的生产机器是一台64位机器。正如预期的那样,该加载项本身安装在c:\program files (x86)
  2. Brought
  3. 下,并按照预期的

加载该加载项

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>
票数 12
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55815546

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档