WIX Installer - is there any automated way of managing Product ID / Code?

前端 未结 1 1838
南旧
南旧 2021-01-27 00:06

I\'m developing a Windows Service installer using Wix. From what I understand, I should generate a unique Product ID for every Version of the service. This can be easily done by

相关标签:
1条回答
  • 2021-01-27 00:18

    Build Automation: You can use build automation in a number of ways to automate the creation of new product GUIDs and similar. You would pass in values to the WiX project file and such things, but perhaps that is not what you want to maintain. Let me add another option below.


    Major Upgrade Element: I assume you have a major upgrade element in there? It takes care of uninstalling the previous version if configured correctly. Typically you see multiple versions in Add / Remove Programs when you re-build the same version and install on top of the last installation.

    Suggestion: You can manually configure the Upgrade table to uninstall "same version installations". You take out the "auto-magic" of the "MajorUpgrade" element and do things yourself with Upgrade elements (an older way to configure the Upgrade table that yields more detailed control):

    Remove this (or just comment it out):

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

    Add this:

    <!-- The top of your new source - compiler variables, can be overridden at compile time via candle.exe and light.exe switches -->
    <?xml version="1.0" encoding="UTF-8"?>
    <?define MyProductVersion = "2.0.0.0" ?>
    <?define MyUpgradeCode = "88888888-7777-7777-7777-888888888888" ?>
    
    <..>
    
    <Upgrade Id="$(var.MyUpgradeCode)">
      <UpgradeVersion Minimum="$(var.MyProductVersion)" OnlyDetect="yes" IncludeMinimum="yes" Property="DOWNGRADE_DETECTED"  />
      <UpgradeVersion Property="PRODUCTLINE1" IncludeMinimum="yes" IncludeMaximum="yes" Maximum="$(var.MyProductVersion)" Minimum="0.0.0"  />
    </Upgrade>
    
    <..>
    
    <!-- You have to add RemoveExistingProducts to the InstallExecuteSequence table -->
    <InstallExecuteSequence>
      <!-- Potential scheduling (after): InstallValidate, InstallInitialize, InstallExecute, InstallExecuteAgain, InstallFinalize -->
      <RemoveExistingProducts After="InstallInitialize" />
    </InstallExecuteSequence>
    

    Summary: The above should let you rebuild your setup and install any number of times using the same version number and the installation process will remove prior installation "auto-magically". Please test. No guarantees. Murphy's law. Etc... :-).


    Some Links:

    • Adding entries to MSI UpgradeTable to remove related products
    • Doing Major Upgrade in Wix creates 2 entries in Add/Remove Programs
    • WIX does not uninstall older version (list of common major upgrade problems)
    0 讨论(0)
提交回复
热议问题