3

使用 Wix 为我正在处理的应用程序创建 Windows 安装程序设置时,我遇到了一个奇怪的问题。

基本上,当应用程序卸载时,它似乎是在完成卸载之前启动应用程序的可执行文件。我不确定它为什么会这样做,因为我是 Wix 的新手。

这是我从这里得到的完整的 Wix 代码。

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define Product_Name="Orbit Invoice System"?>
  <?define Product_Manufacturer="Orbit"?>
  <?define Product_Name_Short="OIS"?>
  <?define Product_Manufacturer_Short="Orbit"?>
  <?define MainExeID="MainExeID"?>
  <!--<?define Product_Version=!(bind.fileVersion.$(var.MainExeID))?>-->
  <?define Product_Version=!(bind.assemblyVersion.$(var.MainExeID))?>
  <?define SetupResourcesDir=$(var.SolutionDir)\icons\?>

  <Product Id="*" Name="$(var.Product_Name)" Version="$(var.Product_Version)" Manufacturer="$(var.Product_Manufacturer)"
           Language="1033"
           UpgradeCode="F9A23E67-669B-40E5-9995-D8425D08F35F">

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <!--Check for .Net Framework 3.5 SP 1-->
    <PropertyRef Id='NETFRAMEWORK40FULL'/>
    <Condition Message="This application requires .NET Framework 4.0. Please install the .NET Framework then run this installer again.">
      <![CDATA[Installed OR NETFRAMEWORK40FULL]]>
    </Condition>

    <MajorUpgrade DowngradeErrorMessage="A newer version of $(var.Product_Name) is already installed."
                  Schedule="afterInstallValidate"
                  />

    <MediaTemplate EmbedCab="yes" />

    <Feature Id="ProductFeature" Title="$(var.Product_Name) Setup" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>

    <!--Icon must be 16x16-->
    <Icon Id="AddRemoveProgramsIcon" SourceFile="$(var.SetupResourcesDir)libra.ico"/>
    <Property Id="ARPPRODUCTICON" Value="AddRemoveProgramsIcon" />
    <!--<Property Id="ARPHELPLINK" Value="" />-->

    <InstallExecuteSequence>
      <Custom Action="CleanUpUserData" After="InstallInitialize">Installed AND NOT UPGRADINGPRODUCTCODE AND NOT REINSTALL</Custom>
      <!--<Custom Action="LaunchApplication" Before="InstallFinalize" >UPGRADINGPRODUCTCODE OR REINSTALL OR NOT Installed</Custom>-->
    </InstallExecuteSequence>

  </Product>

  <Fragment>
    <CustomAction Id="CleanUpUserData" FileKey="$(var.MainExeID)" ExeCommand="cleanUpUserData" Execute="immediate" Impersonate="yes" Return="ignore"/>
    <!--<CustomAction Id="LaunchApplication" FileKey="$(var.MainExeID)" ExeCommand="mustBeSomethingOrTheUpdateWillFailWithError2753" Execute="commit" Impersonate="yes" Return="asyncNoWait"/>-->
  </Fragment>

  <!--Directory general structure-->
  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <!--Program Files-->
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="$(var.Product_Name)" />
      </Directory>
      <!--Startup Programs Menu-->
      <Directory Id="ProgramMenuFolder" Name="Programs">
        <Directory Id="ProgramMenuDir" Name="$(var.Product_Manufacturer)">
          <Component Id="ProgramMenuDir" Guid="*" >
            <Shortcut Id="UninstallProduct"
                      Name="Uninstall $(var.Product_Name)"
                      Target="[SystemFolder]msiexec.exe"
                      Arguments="/x [ProductCode]"
                      Description="Uninstalls $(var.Product_Name)" />
            <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
            <RegistryValue Root='HKCU' Key='Software\$(var.Product_Manufacturer_Short)\$(var.Product_Name_Short)' Type='string' Value='' KeyPath='yes' />
          </Component>
        </Directory>
      </Directory>
      <!--Desktop-->
      <Directory Id="DesktopFolder" Name="Desktop" />
    </Directory>
  </Fragment>

  <!--Directory file structure-->
  <Fragment>
    <DirectoryRef Id="INSTALLFOLDER">
      <Component Id="MainExecutable" Guid="*">
        <File Id="$(var.MainExeID)" Name="$(var.Product_Name).exe" Source="$(var.Invoice.TargetPath)" DiskId="1" KeyPath="yes" Vital="yes"
              Assembly=".net" AssemblyApplication="$(var.MainExeID)">
          <Shortcut Id="MainExeDesktop" Directory="DesktopFolder" Name="$(var.Product_Name)" WorkingDirectory="INSTALLFOLDER"
                    Icon="MainExeIcon.exe"
                    Description="Launches the $(var.Product_Name) application" Advertise="yes" >
            <Icon Id="MainExeIcon.exe" SourceFile="$(var.Invoice.TargetPath)"/>
          </Shortcut>
          <Shortcut Id="MainExeProgramMenu" Directory="ProgramMenuDir" Name="$(var.Product_Name)" WorkingDirectory="INSTALLFOLDER"
                    Icon="MainExeIcon.exe"
                    Description="Launches the $(var.Product_Name) application" Advertise="yes" />
          <Shortcut Id="CleanUpLocalFiles" Directory="ProgramMenuDir" Name="CleanUp the Local Files" Arguments="cleanUpUserData" WorkingDirectory="INSTALLFOLDER"
                    Icon="MainExeIcon.exe"
                    Description="Cleanup all the downloaded files of the $(var.Product_Name) for the current user" Advertise="yes"/>
        </File>
      </Component>
      <Component Id="MainExecutableConfig" Guid="BDFC3501-CB6A-4C75-A4AE-05C0F7FE2DC2">
        <File Id="MainExeConfig" Name="$(var.Product_Name).exe.config" Source="$(var.Invoice.TargetPath).config" DiskId="1" KeyPath="yes" Vital="yes" />
        <File Id="InvoiceConfig" Name="InvoiceConfiguration.dll" Source="$(var.Invoice.TargetDir)\InvoiceConfiguration.dll" DiskId="1" Vital="yes" />
        <File Id="DocumentFormatOpenXml" Name="DocumentFormat.OpenXml.dll" Source="$(var.Invoice.TargetDir)\DocumentFormat.OpenXml.dll" DiskId="1" Vital="yes" />
        <File Id="SalesInvoiceTemplate" Name="SalesInvoiceTemplate.docx" Source="$(var.Invoice.TargetDir)\SalesInvoiceTemplate.docx" DiskId="1" Vital="yes" />
      </Component>
    </DirectoryRef>
  </Fragment>

  <!--Components groups-->
  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <ComponentRef Id="MainExecutable" />
      <!--<ComponentRef Id="Dlls" />
      <ComponentRef Id="LetterTemplates"/>-->
      <ComponentRef Id="MainExecutableConfig" />
      <ComponentRef Id="ProgramMenuDir" />
    </ComponentGroup>
  </Fragment>
</Wix>

有任何想法吗?

4

2 回答 2

4

CleanUpUserData自定义操作运行 $(var.MainExeID) 应用程序。

<CustomAction Id="CleanUpUserData" FileKey="$(var.MainExeID)" ExeCommand="cleanUpUserData" Execute="immediate" Impersonate="yes" Return="ignore"/>

以下条件(安装且未升级产品代码且未重新安装)表示如果安装程序已安装且未升级或重新安装,则将运行自定义操作。所以它会在Repairor中运行Uninstall(两者都会满足这个条件)。所以您的应用程序正在卸载中运行。

<Custom Action="CleanUpUserData" After="InstallInitialize">Installed AND NOT UPGRADINGPRODUCTCODE AND NOT REINSTALL</Custom>

在此处查看有关安装和卸载条件的更多信息。

于 2013-06-03T12:34:29.847 回答
1

查看@Vinoth 给出的答案后,我将“CleanUpUserData”自定义操作更改为:

<Custom Action="CleanUpUserData" After="InstallInitialize">INSTALLED OR UPGRADINGPRODUCTCODE OR REINSTALL</Custom>

现在这已经解决了这个问题。

于 2013-06-03T12:28:33.367 回答