1

I am setting up an msi for this work project and I am trying to make IIS a pre-requisite.

I am new at this so I am not really sure what I am doing wrong. The problem I am facing now is that the error dialogue box keeps popping up no matter the iis version I state that's required. Below are the codes for the custom action and the product.wxs code.

Product.wxs

<PropertyRef Id="IISMAJORVERSION" />
<CustomAction Id='Iis.CheckInstalledVersion.SetProperty'
Property='Iis.CheckInstalledVersion' Execute='immediate' Value='' />
<Binary Id="CheckIis" SourceFile="..\CustomAction\bin\Debug\CustomAction.CA.dll" />
<CustomAction Id='Iis.CheckInstalledVersion' BinaryKey='CheckIis'
DllEntry='CheckInstalledIisVersion' Execute='immediate' Return='check' Impersonate='no' />
<InstallExecuteSequence>
   <Custom Action="Iis.CheckInstalledVersion.SetProperty" Before="LaunchConditions" />
   <Custom Action="Iis.CheckInstalledVersion" After="Iis.CheckInstalledVersion.SetProperty" />
</InstallExecuteSequence>
<Condition Message="This application requires IIS 7 or higher. Please run this installer again on a server with the correct IIS version.">
   <![CDATA[Iis.IsRequiredVersion > 0]]>
</Condition>

CustomAction.cs

public static ActionResult CheckInstalledIisVersion(Session session)
        {
            try
            {
                session.Log("* Starting to check installed IIS version");
                const int IisRequiredVersion = 0;

                string iisMajorVersionFromRegistry = session["IISMINORVERSION"];
                session.Log(string.Format("*!*! DEBUG; CheckInstalledIisVersion; IIS major version: {0}", iisMajorVersionFromRegistry));
                string iisMajorVersionNumeric = iisMajorVersionFromRegistry.Replace("#", string.Empty);
                int iisMajorVersion = int.Parse(iisMajorVersionNumeric, CultureInfo.InvariantCulture);

                bool isRequiredVersion = iisMajorVersion >= IisRequiredVersion;

                // Setting the required version as a custom property, so that it can be used in the condition message
                session["Iis.RequiredVersion"] = IisRequiredVersion.ToString(CultureInfo.InvariantCulture);
                // Setting the results of the check as "bool"
                session["Iis.IsRequiredVersion"] = isRequiredVersion ? "1" : "0";

                return ActionResult.Success;
            }
            catch (Exception ex)
            {
                session.Log(string.Format("CheckInstalledIisVersion; Error occured: {0}", ex.Message));
                return ActionResult.Failure;
            }
        }

I am expecting to get no error messages but currently, I'm still getting error messages even though I have IIS 10.

Adam Loh
  • 111
  • 1
  • 9
  • Are you stepping through the code properly? [Here is how to get proper debugging features for custom action code](https://stackoverflow.com/a/52880033/129130). Watch the short video from the Advanced Installer guys. Also there are the [IISMAJORVERSION and IISMINORVERSION properties](https://stackoverflow.com/q/45691727/129130) from the IIS namespace of WiX. Not up to speed on all of it. Name clashes? – Stein Åsmul Sep 30 '19 at 10:23

0 Answers0