Installation VSTO安装软件包如何检查先决条件并跳过它们

Installation VSTO安装软件包如何检查先决条件并跳过它们,installation,interop,assemblies,ms-office,skip,Installation,Interop,Assemblies,Ms Office,Skip,我根据以下文章为我的Excel加载项项目创建了安装项目: 使用Windows Installer为2007 Microsoft Office System部署Visual Studio Tools for Office System 3.0解决方案 我添加了一些先决条件,如2007互操作汇编Office2007PIA和何时 我运行我的安装文件,它确实安装了它。 但问题是: 我的安装程序总是安装它,即使我的计算机已经安装了 办公室2007年PIA 我如何配置安装项目,它将首先检查 Office20

我根据以下文章为我的Excel加载项项目创建了安装项目:

使用Windows Installer为2007 Microsoft Office System部署Visual Studio Tools for Office System 3.0解决方案

我添加了一些先决条件,如2007互操作汇编Office2007PIA和何时 我运行我的安装文件,它确实安装了它。 但问题是: 我的安装程序总是安装它,即使我的计算机已经安装了 办公室2007年PIA

我如何配置安装项目,它将首先检查 Office2007PIA已安装并继续安装我的项目 没有安装Office2007PIA

以下是c:\Program Files x86\Microsoft SDK\Windows\v6.0A\Bootstrapper\Packages\Office2007PIA\en\package.xml中的代码:

<Package
  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
  Name="DisplayName"
  Culture="Culture"
>

  <!-- Defines a localizable string table for error messages. -->
  <Strings>
    <String Name="DisplayName">2007 Microsoft Office Primary Interop Assemblies</String>
    <String Name="Culture">en</String>
    <String Name="AdminRequired">Administrator permissions are required to install the 2007 Microsoft Office Primary Interop Assemblies. Contact your administrator.</String>
    <String Name="GeneralFailure">A failure occurred attempting to install Microsoft Office 2003 primary interop assemblies.</String>
  </Strings>
</Package>
这是来自的代码 c:\Program Files x86\Microsoft SDK\Windows\v6.0A\Bootstrapper\Packages\Office2007PIA\en\package.xml c:\Program Files x86\Microsoft SDK\Windows\v6.0A\Bootstrapper\Packages\Office2007PIA\product.xml:

<Product
  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
  ProductCode="Microsoft.Office.PIA.2007"
  >

  <RelatedProducts>
    <DependsOnProduct Code="Microsoft.Net.Framework.2.0" />
  </RelatedProducts>

  <!-- Defines the list of files to be copied on build. -->
  <PackageFiles>
    <PackageFile Name="o2007pia.msi"/>
    <PackageFile Name="ComponentCheck.exe"/>
  </PackageFiles>

  <InstallChecks>
     <ExternalCheck 
      Property="Office2007Exists" 
      PackageFile="ComponentCheck.exe" 
      Arguments="{0638C49D-BB8B-4CD1-B191-050E8F325736}"/>
  </InstallChecks>

  <!-- Defines how to run the Setup package. -->
  <Commands Reboot="Defer">

    <Command PackageFile="o2007pia.msi" 
      Arguments=""
      EstimatedInstalledBytes="30000000" 
      EstimatedInstallSeconds="60"
      >

      <InstallConditions>
        <BypassIf Property="Office2007Exists" Compare="ValueNotEqualTo" Value="0" />
        <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
      </InstallConditions>

      <ExitCodes>
        <ExitCode Value="0" Result="Success"/>
        <ExitCode Value="1641" Result="SuccessReboot"/>
        <ExitCode Value="3010" Result="SuccessReboot"/>
        <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
      </ExitCodes>
    </Command>
  </Commands>
</Product>
我想您的意思是product.xml在节点安装条件中缺少代码:


我猜安装不是通过管理权限完成的,因为这是将程序集安装到GAC时的一项要求

如果您想深入了解,可以分析PIA安装的触发过程:

Office PIA是否已安装取决于安装引导程序中包含的一个小的可执行文件,该文件检查PIA是否确实存在于磁盘上

可执行文件名为ComponentCheck.exe,通常位于

C:\Program Files\Microsoft SDK\Windows\v6.0A\Bootstrapper\Packages\Office2007PIARedist

我建议您运行此程序,并使用Process Monitor检查是否有任何故障。根据ComponentCheck.exe的退出代码,是否触发PIAs的安装

此退出代码条件在同一文件夹的package.xml文件中指定:

<InstallConditions>
 <BypassIf Property="PIAInstallAction" Compare="ValueNotEqualTo" Value="0" /> 
   <!-- Requires the user to be an admin user when installing the prerequisite --> 
   <FailIf Property="AdminUser" Compare="ValueEqualTo" 
           Value="false" String="AdminRequired" /> 
</InstallConditions>

我的猜测是,安装不是使用管理权限完成的,因为这是将程序集安装到GAC时的一项要求

如果您想深入了解,可以分析PIA安装的触发过程:

Office PIA是否已安装取决于安装引导程序中包含的一个小的可执行文件,该文件检查PIA是否确实存在于磁盘上

可执行文件名为ComponentCheck.exe,通常位于

C:\Program Files\Microsoft SDK\Windows\v6.0A\Bootstrapper\Packages\Office2007PIARedist

我建议您运行此程序,并使用Process Monitor检查是否有任何故障。根据ComponentCheck.exe的退出代码,是否触发PIAs的安装

此退出代码条件在同一文件夹的package.xml文件中指定:

<InstallConditions>
 <BypassIf Property="PIAInstallAction" Compare="ValueNotEqualTo" Value="0" /> 
   <!-- Requires the user to be an admin user when installing the prerequisite --> 
   <FailIf Property="AdminUser" Compare="ValueEqualTo" 
           Value="false" String="AdminRequired" /> 
</InstallConditions>