2013-06-03 33 views
3

使用Wix为我正在处理的应用程序创建Windows Installer安装程序时,出现了一个奇怪的问题。Wix在卸载时启动应用程序

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

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

<?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

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

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

以下条件(安装后未UPGRADINGPRODUCTCODE和无法重新安装)表示,如果安装设置,而不是在升级的自定义操作将运行或重新安装。所以它会运行在RepairUninstall(都将满足这个条件)。因此,您的应用程序正在卸载中运行。

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

查看更多关于安装和卸载条件here

1

审查通过@Vinoth给出的答案后,我已经改变了“CleanUpUserData”自定义操作的:

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

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