First cut: normally once you designate an UpgradeCode for whatever
represents a product, you never change it. Always use the same UpgradeCode
(Product/@Upgrade value) between your products that are intended to replace
each other/be mutually exclusive.

-----Original Message-----
From: fragorl [mailto:frag...@gmail.com] 
Sent: Monday, May 24, 2010 7:19 PM
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] Major Upgrade - Cannot get preventing downgrades to
work


I've followed the instructions in WiX.chm to the T, and also used the code
from the tutorial (http://www.tramontana.co.hu/wix/lesson4.php#4.1) - using
this code here
(http://www.tramontana.co.hu/wix/download.php?file=samples/sampleupgrade.zip
&type=application/zip).
I cannot for the life of me get WiX to build MSIs that prevent downgrading,
so I'm wondering what I'm doing wrong.

My own files look like this: 

First version (3.0.1, version code 3.0.101)

<code>

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";>
  <Product Id="*" Name="MyProduct 3.0.1 (windows)" Language="1033"
Version="3.0.101" Manufacturer="MyCompany"
UpgradeCode="9A7F3EA0-634B-3751-8FE3-0CBB95B43196">
    <Package Description="An installer for Myproduct" Comments="Test only,
does not work" Manufacturer="MyCompany" InstallerVersion="300"
Platform="x86" Compressed="yes" />
    <Condition Message="A later version of this product is already
installed. Setup will now exit. If you were intentionally trying to do this,
please uninstall the older version manually first.">NOT
PRODUCT_DOWNGRADE</Condition>
    <Media Id="1" Cabinet="data.cab" EmbedCab="yes" />
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Component Id="RegistryComponent"
Guid="970094A6-FF5D-3C39-9E8E-DC1524831863" Win64="no" Permanent="yes">
        <RegistryKey Action="create" Key="Software\MyCompany\MyProduct"
Root="HKLM">
          <RegistryValue Type="string" Name="InstallDir"
Value="[INSTALLDIR]" />
        </RegistryKey>
      </Component>
      <Directory Id="ProgramFilesFolder" Name="PFiles">
        <Directory Id="INSTALLDIR" Name="MyProduct"
FileSource="C:\MyProduct\">
          <Component Id="Component1"
Guid="4FF8421C-80B0-33E4-96B3-E9C7C883045F" Win64="no">
            <File Id="File1" Name="sample.file" DiskId="1" KeyPath="yes" />
          </Component>
          
          ... hierarchy continues ...
       
        </Directory>
      </Directory>
    </Directory>
    <Feature Id="MyProductMainFeature" Title="MyProduct" Level="1">
      <ComponentRef Id="Component1" />
      <ComponentRef Id="RegistryComponent" />
      
      .. more components ...
      
    </Feature>
    <Upgrade Id="9A7F3EA0-634B-3751-8FE3-0CBB95B43196">
      <UpgradeVersion Minimum="1.0.0" IncludeMinimum="yes"
IncludeMaximum="no" Maximum="3.0.101" Property="PRODUCT_UPGRADE" />
      <UpgradeVersion Minimum="3.0.101" IncludeMinimum="no"
Property="PRODUCT_DOWNGRADE" />
    </Upgrade>
    <CustomAction Id="PreventDowngrade" Error="A more recent version than
[ProductName] is already installed. If you are intentionally installing an
older version, please remove the more recent one first." />
    <InstallExecuteSequence>
      <Custom Action="PreventDowngrade"
After="FindRelatedProducts">PRODUCT_DOWNGRADE</Custom>
      <RemoveExistingProducts After="InstallInitialize" />
    </InstallExecuteSequence>
    <InstallUISequence>
      <Custom Action="PreventDowngrade"
After="FindRelatedProducts">PRODUCT_DOWNGRADE</Custom>
      <LaunchConditions After="AppSearch" />
    </InstallUISequence>
    <Property Id="INSTALLDIR">
      <RegistrySearch Id="RegistrySearch01" Type="raw" Root="HKLM"
Win64="no" Key="Software\MyCompany\MyProduct" Name="InstallDir" />
    </Property>
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
    <WixVariable Id="WixUILicenseRtf" Value="C:\MyProduct\License.rtf" />
    <UIRef Id="WixUI_InstallDir" />
    <Icon Id="iconfile"
SourceFile="C:\MyProduct\resources\images\myproduct_windows_all.ico" />
    <Property Id="ARPPRODUCTICON" Value="iconfile" />
  </Product>
</Wix>


</code>

Second version (3.0.2, version code 3.0.201)

<code>

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";>
  <Product Id="*" Name="MyProduct 3.0.2 (windows)" Language="1033"
Version="3.0.201" Manufacturer="MyCompany"
UpgradeCode="6F683F09-2B91-3DD8-A30D-8A7A64073199">
    <Package Description="An installer for Myproduct" Comments="Test only,
does not work" Manufacturer="MyCompany" InstallerVersion="300"
Platform="x86" Compressed="yes" />
    <Condition Message="A later version of this product is already
installed. Setup will now exit. If you were intentionally trying to do this,
please uninstall the older version manually first.">NOT
PRODUCT_DOWNGRADE</Condition>
    <Media Id="1" Cabinet="data.cab" EmbedCab="yes" />
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Component Id="RegistryComponent"
Guid="F4F37A98-791F-3BAC-B5AA-51B328155601" Win64="no" Permanent="yes">
        <RegistryKey Action="create" Key="Software\MyCompany\MyProduct"
Root="HKLM">
          <RegistryValue Type="string" Name="InstallDir"
Value="[INSTALLDIR]" />
        </RegistryKey>
      </Component>
      <Directory Id="ProgramFilesFolder" Name="PFiles">
        <Directory Id="INSTALLDIR" Name="MyProduct"
FileSource="C:\MyProduct\">
          <Component Id="Component1"
Guid="380CDBB7-FB3E-38F2-944E-700902491D5E" Win64="no">
            <File Id="File1" Name="sample.file" DiskId="1" KeyPath="yes" />
          </Component>
          
          ... hierarchy continues ...
       
        </Directory>
      </Directory>
    </Directory>
    <Feature Id="MyProductMainFeature" Title="MyProduct" Level="1">
      <ComponentRef Id="Component1" />
      <ComponentRef Id="RegistryComponent" />
      
      .. more components ...
      
    </Feature>
    <Upgrade Id="6F683F09-2B91-3DD8-A30D-8A7A64073199">
      <UpgradeVersion Minimum="1.0.0" IncludeMinimum="yes"
IncludeMaximum="no" Maximum="3.0.201" Property="PRODUCT_UPGRADE" />
      <UpgradeVersion Minimum="3.0.201" IncludeMinimum="no"
Property="PRODUCT_DOWNGRADE" />
    </Upgrade>
    <CustomAction Id="PreventDowngrade" Error="A more recent version than
[ProductName] is already installed. If you are intentionally installing an
older version, please remove the more recent one first." />
    <InstallExecuteSequence>
      <Custom Action="PreventDowngrade"
After="FindRelatedProducts">PRODUCT_DOWNGRADE</Custom>
      <RemoveExistingProducts After="InstallInitialize" />
    </InstallExecuteSequence>
    <InstallUISequence>
      <Custom Action="PreventDowngrade"
After="FindRelatedProducts">PRODUCT_DOWNGRADE</Custom>
      <LaunchConditions After="AppSearch" />
    </InstallUISequence>
    <Property Id="INSTALLDIR">
      <RegistrySearch Id="RegistrySearch01" Type="raw" Root="HKLM"
Win64="no" Key="Software\MyCompany\MyProduct" Name="InstallDir" />
    </Property>
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
    <WixVariable Id="WixUILicenseRtf" Value="C:\MyProduct\License.rtf" />
    <UIRef Id="WixUI_InstallDir" />
    <Icon Id="iconfile"
SourceFile="C:\MyProduct\resources\images\myproduct_windows_all.ico" />
    <Property Id="ARPPRODUCTICON" Value="iconfile" />
  </Product>
</Wix>

</code>

I'm so sure that I've done everything according to the tutorials, but no
matter what I try, the first msi happily installs itself over the second,
even though the second is of higher version number than the first. I end up
with both versions in the add remove programs menu.

I've tried both my own files here  and the tutorial files I mentioned at the
top of the post, I've tried installing them on both vista and XP, same
behaviour. 

The only common factor i can think of is the set of commands I'm using
something to build the wixobj and msi files - maybe they're somehow munching
the upgrade behaviour. Here they are (slightly edited, but to give a general
idea):

"C:\Program Files (x86)\Windows Installer XML v3\bin\candle.exe" -v
C:\Users\Me\<name of file>.wxs -o C:\Users\Me

"C:\Program Files (x86)\Windows Installer XML v3\bin\light.exe" -ext
"C:\Program Files (x86)\Windows Installer XML v3\bin\WixUIExtension.dll"
-cultures:en-us C:\Users\Me\<name of file>.wixobj -o C:\Users\Alex\<name of
msi>.msi

Any help would be greatly appreciated. Any further information required to
help me resolve this I'll gladly give.

Thanks in advance,

frag
-- 
View this message in context:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Major-Upgrade-
Cannot-get-preventing-downgrades-to-work-tp5096599p5096599.html
Sent from the wix-users mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--

_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


------------------------------------------------------------------------------

_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to