2013-06-03 38 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> 

而現在這已經解決了這個問題。