Wix:如何将 .XLL 文件复制到 Excel 依赖于 Excel 版本的公共 LIBRARY 文件夹?
Wix: How to copy .XLL files to Excel's common LIBRARY folder that is Excel version dependent?
我是 WiX 的新手,正在尝试创建一个安装程序来分发我创建的一些 Excel 加载项(.XLL 文件)。
我现在知道如何将我的文件放到当前用户的 Excel 插件库文件夹中,该文件夹已经 %AppData%\Microsoft\AddIns 多年,现在 o/s 版本。
但是,我还需要将几个 .XLL 文件复制(但 不是 激活)到 Excel 的 common/shared 插件库文件夹那是 Excel 版本依赖。例如..\Office11\LIBRARY, ..\Office14\LIBRARY等
无论安装的 Excel 版本如何,我如何编写脚本以确保我的安装程序将 .XLL 文件正确复制到 common/shared "OfficeXX\LIBRARY" 文件夹?
当我使用 InstallShield 时,我依赖 Excel 自动化对象中的 LibraryPath() 函数,它可以直接从 IS 脚本访问。
在 WiX 中,我是否被迫创建一个自定义操作项目来访问 Excel 对象以读取库路径?
谢谢你的时间。
无需自定义操作即可解决此问题,但如果您想支持许多不同版本的 office,此解决方案最终可能会非常冗长。一般的想法是使用 <RegistrySearch.../>
将 属性 设置为特定版本的 office 的位置。然后使用 属性 作为目录位置和组件的条件。
一个小问题:用作 Directory element should be a copy of the property found by registry search. If we try and use the same property returned by the registry search, the Directory 元素的 Directory 属性的 属性 会将 属性 设置为已解析的目录location,这会将条件设置为 true 并安装组件。
2010 年 Excel 的 <RegistrySearch.../>
:
<!-- Search for Excel 2010 -->
<Property Id="OFFICE14LOCATION">
<RegistrySearch Id="Office14Location"
Root="HKLM"
Key="SOFTWARE\Microsoft\Office.0\Excel\InstallRoot"
Name="Path"
Type="raw"/>
</Property>
<!-- Make a copy of the property for the directory reference -->
<SetProperty Id="Office14DirectoryPath" Value="[OFFICE14LOCATION]" Before="CostFinalize"/>
Excel2010 年的组成部分:
<!-- Conditionally install MyAddIn.xll to the Office14\Library directory
Remember to reference Office14Library in a <Feature> -->
<DirectoryRef Id="Office14Library">
<Component Id="Office14AddIn" Guid="-- your GUID --">
<Condition>OFFICE14LOCATION</Condition>
<File Id="Office14AddIn" Name="MyAddIn.xll" Source="MyAddIn.xll" />
</Component>
</DirectoryRef>
Excel 2010 的目录部分:
<!-- Note: Include this as a child of <Directory Id="TARGETDIR" ..> -->
<Directory Id="Office14DirectoryPath" Name="Office14"> <!-- Note: The Name attribute is redundant but needed to avoid ICE30 warning -->
<Directory Id="Office14Library" Name="Library"/>
</Directory>
您需要为支持的每个 office 版本重复上述步骤。
Excel 2007
要支持 Excel 2007,您可以将上例中对 14 的引用更改为 12。例如:
<!-- Search for Excel 2007-->
<Property Id="OFFICE12LOCATION">
<RegistrySearch Id="Office12Location"
Root="HKLM"
Key="SOFTWARE\Microsoft\Office.0\Excel\InstallRoot"
Name="Path"
Type="raw"/>
</Property>
<!-- Make a copy of the property for the directory reference -->
<SetProperty Id="Office12DirectoryPath" Value="[OFFICE12LOCATION]" Before="CostFinalize"/>
<!-- Conditionally install MyAddIn.xll to the Office12\Library directory
Remember to reference Office12Library in a <Feature> -->
<DirectoryRef Id="Office12Library">
<Component Id="Office12AddIn" Guid="-- your GUID --">
<Condition>OFFICE12LOCATION</Condition>
<File Id="Office12AddIn" Name="MyAddIn.xll" Source="MyAddIn.xll" />
</Component>
</DirectoryRef>
<!-- Note: Include this as a child of <Directory Id="TARGETDIR" ..> -->
<Directory Id="Office12DirectoryPath" Name="Office12"> <!-- Note: The Name attribute is redundant but needed to avoid ICE30 warning -->
<Directory Id="Office12Library" Name="Library"/>
</Directory>
64位Excel2010
该解决方案还可以扩展以支持 Excel 2010 的 64 位版本:
64 位的 <RegistrySearch.../>
Excel 2010:
<!-- Search for 64 bit Excel 2010 -->
<Property Id="OFFICE14LOCATIONX64">
<RegistrySearch Id="Office14LocationX64"
Root="HKLM"
Key="SOFTWARE\Microsoft\Office.0\Excel\InstallRoot"
Name="Path"
Win64="yes"
Type="raw"/>
</Property>
<!-- Make a copy of the property for the directory reference -->
<SetProperty Id="Office14DirectoryPathX64" Value="[OFFICE14LOCATIONX64]" Before="CostFinalize"/>
64 位的组成部分 Excel 2010:
<!-- Conditionally install MyAddIn.xll to the Office14\Library directory
Remember to reference Office14Library in a <Feature> -->
<DirectoryRef Id="Office14LibraryX64">
<Component Id="Office14AddInX64" Win64="yes" Guid="-- your GUID --">
<Condition>OFFICE14LOCATIONX64</Condition>
<File Id="Office14AddInX64" Name="MyAddIn.xll" Source="MyAddIn.xll" />
</Component>
</DirectoryRef>
64 位的目录部分 Excel 2010:
<!-- Note: Include this as a child of <Directory Id="TARGETDIR" ..> -->
<Directory Id="Office14DirectoryPathX64" Name="Office14X64"> <!-- Note: The Name attribute is redundant but needed to avoid ICE30 warning -->
<Directory Id="Office14LibraryX64" Name="Library"/>
</Directory>
有用的参考:
How to detect installed version of MS-Office?
How do you copy a set of files to multiple places using Wix?
我是 WiX 的新手,正在尝试创建一个安装程序来分发我创建的一些 Excel 加载项(.XLL 文件)。
我现在知道如何将我的文件放到当前用户的 Excel 插件库文件夹中,该文件夹已经 %AppData%\Microsoft\AddIns 多年,现在 o/s 版本。
但是,我还需要将几个 .XLL 文件复制(但 不是 激活)到 Excel 的 common/shared 插件库文件夹那是 Excel 版本依赖。例如..\Office11\LIBRARY, ..\Office14\LIBRARY等
无论安装的 Excel 版本如何,我如何编写脚本以确保我的安装程序将 .XLL 文件正确复制到 common/shared "OfficeXX\LIBRARY" 文件夹?
当我使用 InstallShield 时,我依赖 Excel 自动化对象中的 LibraryPath() 函数,它可以直接从 IS 脚本访问。
在 WiX 中,我是否被迫创建一个自定义操作项目来访问 Excel 对象以读取库路径?
谢谢你的时间。
无需自定义操作即可解决此问题,但如果您想支持许多不同版本的 office,此解决方案最终可能会非常冗长。一般的想法是使用 <RegistrySearch.../>
将 属性 设置为特定版本的 office 的位置。然后使用 属性 作为目录位置和组件的条件。
一个小问题:用作 Directory element should be a copy of the property found by registry search. If we try and use the same property returned by the registry search, the Directory 元素的 Directory 属性的 属性 会将 属性 设置为已解析的目录location,这会将条件设置为 true 并安装组件。
2010 年 Excel 的 <RegistrySearch.../>
:
<!-- Search for Excel 2010 -->
<Property Id="OFFICE14LOCATION">
<RegistrySearch Id="Office14Location"
Root="HKLM"
Key="SOFTWARE\Microsoft\Office.0\Excel\InstallRoot"
Name="Path"
Type="raw"/>
</Property>
<!-- Make a copy of the property for the directory reference -->
<SetProperty Id="Office14DirectoryPath" Value="[OFFICE14LOCATION]" Before="CostFinalize"/>
Excel2010 年的组成部分:
<!-- Conditionally install MyAddIn.xll to the Office14\Library directory
Remember to reference Office14Library in a <Feature> -->
<DirectoryRef Id="Office14Library">
<Component Id="Office14AddIn" Guid="-- your GUID --">
<Condition>OFFICE14LOCATION</Condition>
<File Id="Office14AddIn" Name="MyAddIn.xll" Source="MyAddIn.xll" />
</Component>
</DirectoryRef>
Excel 2010 的目录部分:
<!-- Note: Include this as a child of <Directory Id="TARGETDIR" ..> -->
<Directory Id="Office14DirectoryPath" Name="Office14"> <!-- Note: The Name attribute is redundant but needed to avoid ICE30 warning -->
<Directory Id="Office14Library" Name="Library"/>
</Directory>
您需要为支持的每个 office 版本重复上述步骤。
Excel 2007
要支持 Excel 2007,您可以将上例中对 14 的引用更改为 12。例如:
<!-- Search for Excel 2007-->
<Property Id="OFFICE12LOCATION">
<RegistrySearch Id="Office12Location"
Root="HKLM"
Key="SOFTWARE\Microsoft\Office.0\Excel\InstallRoot"
Name="Path"
Type="raw"/>
</Property>
<!-- Make a copy of the property for the directory reference -->
<SetProperty Id="Office12DirectoryPath" Value="[OFFICE12LOCATION]" Before="CostFinalize"/>
<!-- Conditionally install MyAddIn.xll to the Office12\Library directory
Remember to reference Office12Library in a <Feature> -->
<DirectoryRef Id="Office12Library">
<Component Id="Office12AddIn" Guid="-- your GUID --">
<Condition>OFFICE12LOCATION</Condition>
<File Id="Office12AddIn" Name="MyAddIn.xll" Source="MyAddIn.xll" />
</Component>
</DirectoryRef>
<!-- Note: Include this as a child of <Directory Id="TARGETDIR" ..> -->
<Directory Id="Office12DirectoryPath" Name="Office12"> <!-- Note: The Name attribute is redundant but needed to avoid ICE30 warning -->
<Directory Id="Office12Library" Name="Library"/>
</Directory>
64位Excel2010
该解决方案还可以扩展以支持 Excel 2010 的 64 位版本:
64 位的 <RegistrySearch.../>
Excel 2010:
<!-- Search for 64 bit Excel 2010 -->
<Property Id="OFFICE14LOCATIONX64">
<RegistrySearch Id="Office14LocationX64"
Root="HKLM"
Key="SOFTWARE\Microsoft\Office.0\Excel\InstallRoot"
Name="Path"
Win64="yes"
Type="raw"/>
</Property>
<!-- Make a copy of the property for the directory reference -->
<SetProperty Id="Office14DirectoryPathX64" Value="[OFFICE14LOCATIONX64]" Before="CostFinalize"/>
64 位的组成部分 Excel 2010:
<!-- Conditionally install MyAddIn.xll to the Office14\Library directory
Remember to reference Office14Library in a <Feature> -->
<DirectoryRef Id="Office14LibraryX64">
<Component Id="Office14AddInX64" Win64="yes" Guid="-- your GUID --">
<Condition>OFFICE14LOCATIONX64</Condition>
<File Id="Office14AddInX64" Name="MyAddIn.xll" Source="MyAddIn.xll" />
</Component>
</DirectoryRef>
64 位的目录部分 Excel 2010:
<!-- Note: Include this as a child of <Directory Id="TARGETDIR" ..> -->
<Directory Id="Office14DirectoryPathX64" Name="Office14X64"> <!-- Note: The Name attribute is redundant but needed to avoid ICE30 warning -->
<Directory Id="Office14LibraryX64" Name="Library"/>
</Directory>
有用的参考: How to detect installed version of MS-Office? How do you copy a set of files to multiple places using Wix?