我根据文章为我的 Excel 加载项项目创建了安装项目:
使用 Windows Installer 为 2007 Microsoft Office System 部署适用于 Office System 3.0 解决方案的 Visual Studio 工具
http://msdn.microsoft.com/en-us/library/cc563937(office.12).aspx
我添加了诸如 2007 Interop 程序集(Office2007PIA)之类的先决条件,当我运行我的安装文件时,它会安装它。但问题是:即使我的计算机已经安装了 Office2007PIA,我的设置也总是会安装它。
如何配置我的安装项目,它将首先检查是否安装了 Office2007PIA,然后在不安装 Office2007PIA 的情况下继续安装我的项目?
以下是“c:\Program Files (x86)\Microsoft SDKs\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 SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2007PIA\en\package.xml”的代码“c:\Program Files (x86)\Microsoft SDKs\ 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 缺少代码(在节点InstallConditions中):
<BypassIf Property="PIAInstallAction" Compare="ValueNotEqualTo" Value="0" />
?