Wix中的CustomAction无法执行

Wix中的CustomAction无法执行

本文介绍了Wix中的CustomAction无法执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在创建我的第一个Wix项目,执行自定义操作时似乎遇到了问题.我不确定它是否包含在msi中,也不太确定我做错了什么.以下是我的Wix文件:

So I'm creating my first Wix project and I seem to be having a problem executing a custom action. I'm not sure that it's being included in the msi and I'm not quite sure what I'm doing wrong. The following is my Wix file:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="ExactaDynamicManifest" Language="1033" Version="1.0.0.0" Manufacturer="Bastian Software Solutions" UpgradeCode="274ff2d9-e291-4706-a8db-ce80ccd91538">
      <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/>

      <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
      <MediaTemplate />

      <Feature Id="ProductFeature" Title="ExactaDynamicManifest" Level="1">
        <ComponentGroupRef Id="ExactaDynamicManifest"/>
      </Feature>

      <Icon Id="exacta.ico" SourceFile="icons\exacta.ico"/>
      <Property Id="ARPPRODUCTICON" Value="exacta.ico" />

    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
        <Directory Id="ExactaFolder" Name ="Exacta">
                  <Directory Id="INSTALLFOLDER" Name="ExactaExactaDynamicManifest" />
        </Directory>
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
      <CustomAction Id="InstallService" FileKey="ExactaDynamicManifest.exe" ExeCommand="install"/>
      <InstallExecuteSequence>
        <Custom Action="InstallService" After="InstallFinalize"/>
      </InstallExecuteSequence>
    </Fragment>
</Wix>

最后一个片段包含我的自定义操作,在所有文件都放入目录后,我希望在命令行上执行以下操作:

The last fragment contains my custom action which what I hoped would do is the following on the command line after all files have been placed in the directory:

ExactaDynamicManifest.exe install

要注意的一件事是,exe实际上来自上面定义的 ComponentGroupRef .不知道这是否是一个问题,但以为我会提到它.任何帮助将不胜感激.

One thing to note is that exe is actually coming from a ComponentGroupRef defined above. Not sure if this is a problem or not but thought I'd mention it. Any help would be appreciated.

推荐答案

我终于得到了可以解决的问题.我最初未加载CustomAction的问题似乎是由于它位于不同的<fragment>中.我将所有代码合并为一个片段,它似乎可以运行.

I finally got something that is working. My initial problem of the CustomAction not loading seemed to be due to it being in a different <fragment>. I consolidated all of the code into a single fragment and it seemed to run.

在与用户权限等斗争之后,我最终得到了这个解决方案:

After battling with user permissions etc I finally ended up with this solution:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="ExactaDynamicManifest" Language="1033" Version="1.0.0.0" Manufacturer="Bastian Software Solutions" UpgradeCode="274ff2d9-e291-4706-a8db-ce80ccd91538">
      <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/>

      <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
      <MediaTemplate />

      <Feature Id="ProductFeature" Title="ExactaDynamicManifest" Level="1">
        <ComponentGroupRef Id="ExactaDynamicManifest"/>
      </Feature>

      <Icon Id="exacta.ico" SourceFile="icons\exacta.ico"/>
      <Property Id="ARPPRODUCTICON" Value="exacta.ico" />

    </Product>

    <Fragment>
      <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
          <Directory Id="ExactaFolder" Name ="Exacta">
            <Directory Id="INSTALLFOLDER" Name="ExactaExactaDynamicManifest" />
          </Directory>
        </Directory>
      </Directory>

      <CustomAction Id="RunTopShelfServiceInstall" Directory="INSTALLFOLDER" Execute="deferred" Return="ignore" Impersonate="no" ExeCommand="[INSTALLFOLDER]ExactaDynamicManifest.exe install"/>
      <CustomAction Id="RunTopShelfServiceUninstall" Directory="INSTALLFOLDER" Execute="deferred" Return="ignore" Impersonate="no" ExeCommand="[INSTALLFOLDER]ExactaDynamicManifest.exe uninstall"/>

      <InstallExecuteSequence>
        <Custom Action="RunTopShelfServiceInstall" After="InstallFiles">
          NOT Installed
        </Custom>
        <Custom Action="RunTopShelfServiceUninstall" After='InstallInitialize'>
          (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
        </Custom>
      </InstallExecuteSequence>

    </Fragment>
</Wix>

这篇关于Wix中的CustomAction无法执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 23:43