wix:从commonfiles文件夹运行exe作为自定义操作

时间:2013-06-20 09:19:32

标签: wix vsto

我正在使用VS2012和VSTO构建的Word模板的安装程序。 作为安装程序的一部分,我需要运行位于Common Files Folder中的vstoinstaller。 似乎x86和x64之间的路径不同,所以我认为使用CommonFilesFolder属性是一个很好的解决方案。但是,在构建msi包时出现错误:

Fehler  4   The system cannot find the file '[CommonFilesFolder]Microsoft Shared\VSTO\10.0\VSTOInstaller.exe'.  C:\trash\WordTemplate\WordTemplateSetup\Product.wxs 31  1   WordTemplateSetup

以下是我的wxs的一部分:

<Binary Id="VSTOInstaller.exe" SourceFile="[CommonFilesFolder]Microsoft Shared\VSTO\10.0\VSTOInstaller.exe" />

我发现了几个显示wxs预处理差异的样本,但是我需要在运行时引用正确的目录。

有什么建议吗?

2 个答案:

答案 0 :(得分:0)

源路径(SourceFile属性值)在构建时解析,而MSI变量值[CommonFilesFolder]在运行时解析。

使用WIX变量(如$(var.Variable))来获取构建计算机上的路径。请参阅Using Environment Variables in WiX

但是,我并没有完全理解你想要使用它的方法。如果此代码行(<Binary>元素)来自安装包,则您将无法在另一个内部运行一个安装程序。如果这一行来自Burn bundle,那你为什么不使用<ExePackage>元素?

答案 1 :(得分:0)

最后我做到了:

    <?define VstoInstaller="C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe"?>
<CustomAction Id="RunWordVstoInstall"
              Execute="immediate"
              Directory="INSTALLLOCATION"
              Return="asyncWait"
              ExeCommand="$(var.VstoInstaller) /i [INSTALLLOCATION]\WordTemplateInstaller.vsto" 
              />
<CustomAction Id="RunWordVstoUninstall"
              Execute="immediate"
              Directory="INSTALLLOCATION"
              Return="asyncWait"
              ExeCommand="$(var.VstoInstaller)  /u [INSTALLLOCATION]\WordTemplateInstaller.vsto" 
              />
<InstallExecuteSequence>
  <Custom Action="RunWordVstoUninstall" After="CostFinalize"><![CDATA[(&WordTemplateFeature <> 3)]]></Custom>
  <Custom Action="RunWordVstoInstall" After="CustomizeVsto"><![CDATA[(&WordTemplateFeature = 3)]]></Custom>
</InstallExecuteSequence>

在CustomAction条目中使用“假”DIRECTORY以及变量就可以了。对我很有用。