简体   繁体   中英

Wix Installer to upgrade and remove files + registry entries

I have an application that needs 1. to create DLL files in a Program Files subfolder (eg C:\\Program Files (x86)\\myapp), and 2. to create a registry entry in HKCU. When I run the Remove, I need this subfolder and its files to be deleted, as well as the registry entry. When I run the installation file of a newer version, I need the new DLL files to replace the existing ones.

I've been struggling getting it to work, having tried several tips from various threads and sites. So far I get the Program Files to be removed but not the Registry. And I cannot get the file upgrade to work (I change the UpgradeCode & ProductVersion for each new release)

Here is an extract of what I have

    <Product Id="$(var.ProductID)"
               Name="myapp"
           Language="1033"
           Version="$(var.ProductVersion)"
           UpgradeCode="$(var.UpgradeCode)"
           Manufacturer="$(var.Manufacturer)">    
    <Package Description="Windows installer for myApp $(var.ProductVersion)"
             Comments="Execute to install myApp $(var.ProductVersion)"
            InstallerVersion="200"
            Compressed="yes" />     
<Media Id="1" Cabinet="contents.cab" EmbedCab="yes" CompressionLevel="high"/>
    <Upgrade Id="$(var.UpgradeCode)">
      <UpgradeVersion Minimum="$(var.ProductVersion)"
                     OnlyDetect="yes"
                      Property="NEWERVERSIONDETECTED" />
      <UpgradeVersion Minimum="1.0.0.0"
                      IncludeMinimum="yes"
                      Maximum="$(var.ProductVersion)"
                      IncludeMaximum="no"
                      Property="OLDERVERSIONBEINGUPGRADED" />
    </Upgrade>
    <CustomAction Id="UIandAdvertised" Error="Something about the UI."/>
        <Directory Id="TARGETDIR" Name="SourceDir"/>        
        <Feature Id="Complete"
               Title="myApp"
               Description="Installation of myApp $(var.ProductVersion)"
               Level="1">
             <ComponentRef Id="myAppFiles"/>
                 <ComponentRef Id="RegistryEntry"/>
        </Feature>
    <Property Id="WIXUI_INSTALLDIR">INSTALLDIR</Property>
    <UIRef Id="WixUI_InstallDir"/>    
    <InstallExecuteSequence>
      <RemoveExistingProducts Before="InstallInitialize" />
      <RemoveRegistryValues />
    </InstallExecuteSequence>
  </Product>

My files and reg infos are maintained in a separate file:

<Fragment>
        <DirectoryRef Id="TARGETDIR">
            <Directory Id="ProgramFilesFolder" Name="PFiles">
                <Directory Id="INSTALLDIR" Name="myapp">
                    <Component Id="myAppFiles" Guid="{xxxx-xxxx-xxxx-xxxx-xxxxxxxx}">
          <File Id="myapp.dll" Name="myapp.dll" KeyPath="yes" Source="..\src\bin\x86\Release\myapp.dll" />
          </Component>
                    <Component Id="RegistryEntry" Guid="{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx}" Win64="no" >
                        <RegistryKey Root="HKCU" Key="Software\myapp" Action="createAndRemoveOnUninstall">
              <RegistryValue Type="string" Value="myapp" />
            </RegistryKey>
                    </Component>
                </Directory>
            </Directory>
        </DirectoryRef>

Any help will be highly appreciated.

Use Product ID ="*", It changes product id guid for each build. But keep upgrade code same for product, unless you dont want to support upgrade.

You can use major upgrade tag instead of Upgrade tag. It is easier to use.

<MajorUpgrade AllowDowngrades="no"
              AllowSameVersionUpgrades="no"
              Schedule="afterInstallValidate"
              DowngradeErrorMessage="Newer version of [ProductName] is already installed."/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM