Skip to content

Instantly share code, notes, and snippets.

@LindaLawton
Created July 6, 2016 13:24
Show Gist options
  • Save LindaLawton/1f52c7ff63fe14f7718e3d8e3ce0f5b8 to your computer and use it in GitHub Desktop.
Save LindaLawton/1f52c7ff63fe14f7718e3d8e3ce0f5b8 to your computer and use it in GitHub Desktop.
How to allow upgrade with Wix.
<?xml version="1.0" encoding="UTF-8"?>
<?define ProductVersion="!(bind.FileVersion.MyAssemblyDll)"?>
<?define UpgradeCode="f4d7f199-28f6-45d5-ad99-7c62938274be"?>
<?define ProductId="{6408D956-40DA-4AEE-883E-5425F1562004}"?>
<?define Version="1.0.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="UpgradeTest" Language="1033" Version="$(var.Version)" Manufacturer="xxx" UpgradeCode="$(var.UpgradeCode)">
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<Upgrade Id ="$(var.UpgradeCode)">
<UpgradeVersion Minimum="$(var.Version)" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/>
<UpgradeVersion Maximum="$(var.Version)" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED"/>
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>
<Condition Message="A newer version of [ProductName] is already installed. If you are sure you want to downgrade, remove the existing installation via Programs and Features.">Not NEWERVERSIONDETECTED</Condition>
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="UpgradeTest" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="UpgradeTest" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="ProductComponent">
<File Id="Productwxs" Source="Product.wxs" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
@misulo
Copy link

misulo commented Feb 3, 2020

Quick question: what is the defined ProductId and ProductVersion used for? I don't see them coming up anymore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment