[wix-users] Silent Upgrade Issue

Ven H venh.123 at gmail.com
Wed Jul 11 10:43:21 PDT 2018


I have a Product.wxs file as below.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="CACFB702-D5E1-4B27-82AE-C843E6423688"
Name="SilentInstallSample" Language="1033" Version="1.0.0.0"
Manufacturer="Silent Installer"
UpgradeCode="93928386-B083-4E13-BE9F-6272F8339A04">
    <!--04DCE866-F0B2-45CA-9E7F-032552437436--><!--1.0.0.0-->
    <!--CACFB702-D5E1-4B27-82AE-C843E6423688--><!--2.0.0.0-->
    <Package InstallerVersion="200" Compressed="yes"
InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName]
is already installed." Schedule="afterInstallExecute" />
    <MediaTemplate EmbedCab="yes" />

    <Property Value="1" Id="MSIUSEREALADMINDETECTION"/>
    <Property Value="1" Id="MSIFASTINSTALL"/>
    <Property Value="v" Id="MsiLogging"/>
    <Property Value="1" Id="MSIENFORCEUPGRADECOMPONENTRULES"/>
    <Property Value="0" Id="INSTALL_APP" />
    <Property Value="0" Id="INSTALL_DB" />

    <Feature InstallDefault="local" Description="App Feature Description"
Title="App Feature" Level="1" Id="AppFeature" Absent="allow"
AllowAdvertise="no" Display="expand">
      <ComponentGroupRef Id="AppCG"/>
    </Feature>
    <Feature InstallDefault="local" Description="DB Feature Description"
Title="DB Feature" Level="1" Id="DBFeature" Absent="allow"
AllowAdvertise="no" Display="expand">
      <ComponentGroupRef Id="DbCG"/>
    </Feature>
  <Binary Id="SetFeatureCADLL"
SourceFile="$(var.SolutionDir)SetFeatureCA\bin\debug\SetFeatureCA.CA.dll" />
  <CustomAction Id="CA_SetFeature" BinaryKey="SetFeatureCADLL"
DllEntry="SetFeatures" Execute="immediate" Return="check" />
  <InstallExecuteSequence>
    <Custom Action="CA_SetFeature"
Before="LaunchConditions"><![CDATA[(UILevel <= 3) AND (NOT
REMOVE~="ALL")]]></Custom>
  </InstallExecuteSequence>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLDIR">
          <Directory Id="APP_DIR" Name="SilentInstallApp" />
        </Directory>
        <Directory Id="DB_DIR" Name="SilentInstallDB">
          <Directory Id="DB_LOG_DIR" Name="Log" />
        </Directory>
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="AppCG" Directory="APP_DIR">
      <Component Id="AppCmp" Guid="F21E7372-C85D-4708-8874-A4F6E571442C">
        <File Id="SampleTxt" Name="Sample.txt"
Source="SilentInstallApp\Sample.txt" KeyPath="yes"/>
      </Component>
    </ComponentGroup>
    <ComponentGroup Id="DbCG" Directory="DB_DIR">
      <Component Id="DBCmp" Guid="587B85F9-C545-4660-B8EA-1CCEFE50E539">
        <File Id="StringSearchSQL" Name="StringSearch.sql"
Source="SilentInstallDB\StringSearch.sql" KeyPath="yes"/>
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>


I also have a Custom Action as below.

 [CustomAction]
        public static ActionResult SetFeatures(Session session)
        {
            try
            {
                session.Log("Begin SetFeatures CA...");
                //System.Diagnostics.Debugger.Launch();
                session["ADDLOCAL"] = "ALL";
                if (string.IsNullOrEmpty(session["Installed"]))
                {
                    if (session["INSTALL_APP"] == "")
                    {
                        session["REMOVE"] = "AppFeature";
                    }
                    if (session["INSTALL_DB"] == "")
                    {
                        session["REMOVE"] = "DBFeature";
                    }
                }
                session.Log("End SetFeatures CA...");
                return ActionResult.Success;
            }
            catch (Exception ex)
            {
                session.Log("Exception occurred in SetFeatures CA: " +
ex.ToString());
                return ActionResult.Failure;
            }
        }

I use the following commands for Silent Install.

start /wait msiexec /qn /i MyMSI.msi /l*v App.log INSTALL_APP="1"
INSTALL_DB=""

start /wait msiexec /qn /i MyM.msi /l*v Db.log INSTALL_APP="" INSTALL_DB="1"

This works fine. Now during upgrade, I change the Product ID and Version. I
also change the content of the Sample text file and Sql file for upgrade.
Then when I execute the first command above, it is unfortunately upgrading
both the features. I want to control this behavior. Can anyone please help?


More information about the wix-users mailing list