VSTO 安装包 如何检查先决条件并跳过它们
我根据以下文章为 Excel 加载项项目创建了安装项目:
使用 Windows Installer 为 2007 Microsoft Office System 部署 Visual Studio Tools for the Office System 3.0 解决方案
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" />
:?
I created Setup project for my Excel add-in project according to the article:
Deploying a Visual Studio Tools for the Office System 3.0 Solution for the 2007 Microsoft Office System Using Windows Installer
http://msdn.microsoft.com/en-us/library/cc563937(office.12).aspx
I add prerequisites such as 2007 Interop assemblies(Office2007PIA) and when
I run my setup file it does install it.
But the problem is :
That my setup ALWAYS installs it even if my computer already has
Office2007PIA.
How can I configure my setup project that it will first check if
Office2007PIA is installed and continue the installation of my project
without installing Office2007PIA?
Here is the code from "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>
And here is the code from
"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>
I suppose you mean product.xml is missing code (in node InstallConditions):
<BypassIf Property="PIAInstallAction" Compare="ValueNotEqualTo" Value="0" />
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,安装不是使用管理权限完成的,因为这是将程序集安装到 GAC 时的要求。
如果您想深入了解,可以分析触发 PIA 安装的过程:
是否安装 Office PIA 由安装引导程序中包含的一个小可执行文件决定,该可执行文件检查 PIA 是否实际存在于光盘上。
该可执行文件名为 ComponentCheck.exe,通常位于
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2007PIARedist
下,我建议您运行该程序并使用进程监视器检查是否有任何失败。根据 ComponentCheck.exe 的退出代码,是否触发 PIA 的安装。
此退出代码条件在同一文件夹中的文件 package.xml 中指定:
My guess is that the installation is not done with administrative permissions as this is a requirement when installing assemblies to the GAC.
If you want to dig deeper you can analyze the process how the PIA installation is triggered:
Whether the Office PIA are installed is determined by a small executable included in the setup bootstrapper that checks if the PIA are actually present on disc.
The executable is named ComponentCheck.exe and is typically located under
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2007PIARedist
I suggest you run this program and check with Process Monitor whether anything fails. Based on the exit code of ComponentCheck.exe the installation of the PIAs is triggered or not.
This exit code condition is specified in the file package.xml in the same folder: