0

I am using WiX 3.10. I have a particular scenario where there are some custom actions occurring before the launch conditions because during the launch conditions, I evaluate certain properties that are set during those custom actions. However, during launch conditions, I also have to check the version of .Net framework. The problem is that if I don't have the required .Net Framework, the custom action executes before it reaches the launch condition and the message is not displayed to the user.

Can I execute launch conditions in a specific order or do I have to change the custom action to execute AFTER launch conditions? I need help. Not an expert in WiX.

Code for reference:

<!--Need to execute this first-->
    <PropertyRef Id="NETFRAMEWORK35" />
      <PropertyRef Id="WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED" />
      <Condition Message="This application requires .NET Framework 4.6. Please install the .NET Framework then run this installer again.">
        <![CDATA[Installed OR (NETFRAMEWORK35 = "#1" AND WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED)]]>
      </Condition>

<!--Need to execute this second.  It is execute first through custom action-->
      <PropertyRef Id="SQLSERVERMISSINGREQUIREDSERVICES"/>
      <Condition Message="Please install the following SQL Server services for the SQL Server instance: [SQLSERVERMISSINGREQUIREDSERVICES]. Then run this installer again.">
        <![CDATA[Installed or NOT SQLSERVERMISSINGREQUIREDSERVICES]]>
      </Condition>

<!--Need to execute this third. It is execute second through custom action-->
      <PropertyRef Id="SQLSERVERMAJORVERSION"/>
      <PropertyRef Id="SQLSERVERMINORVERSION" />
      <Condition Message="The GSL server requires a 2008 R2, 2012, or 2014 instance named 'GSLSQL' to be installed on the local server.">
        <![CDATA[Installed OR (SQLSERVERMAJORVERSION = "#10" AND SQLSERVERMINORVERSION >= "#50") OR SQLSERVERMAJORVERSION = "#11" OR SQLSERVERMAJORVERSION = "#12"]]>
      </Condition>
D. Bermudez
  • 217
  • 2
  • 9
  • 20
  • Are the custom actions managed code? (.NET). I didn't test, but the above condition would seem to require .NET 3.5 to be installed, or the installation fails - even if .NET 4.6 is present. So this means that both .NET 3.5 and .NET 4.6 has to be installed to use your application? Is this OK? If Phil's suggestion doesn't work for you, then you probably have to roll with a C++ or ActiveScript custom action to implement your custom checks - to avoid failure when the .NET framework is missing. – Stein Åsmul Aug 27 '18 at 23:34
  • The custom actions are executed BEFORE the launch conditions. They are in a separate DLL that is included as a reference in the installer project. So, I suspect that when the installer is executed, and the target machine does not have the .Net Framework installed, the DLL fails to load and causes the installer to end prematurely. – D. Bermudez Aug 28 '18 at 17:46
  • Yes, hence my mention of C++ and ActiveScripting (VBScript, JavaScript) custom actions. They will generally run in all cases, although script actions are frowned upon. I tolerate them when they make no system changes and inspect only - specifically to avoid .NET runtime dependencies. You need heavy testing, error control and error suppression on such script custom actions for them to not cause problems. – Stein Åsmul Aug 29 '18 at 02:35
  • Thanks...As of today, the client changed the requirements for my task...so now I have to bundle the .Net Framework with the installation. – D. Bermudez Aug 30 '18 at 19:23
  • Very common requirement. IMHO bundling the .NET framework is less and less sensible - seeing as it is going to be outdated quickly as the whole runtime with hotfixes are now installed via Windows Update - normally. [A little rant about outdated prerequisites can be found here](https://stackoverflow.com/a/51977220/129130) (bottom - "Prefer Download"). But just implement what the client asks for - obviously. – Stein Åsmul Aug 30 '18 at 20:54

1 Answers1

2

The general way to sequence this type of condition is to replace the launch conditions with type 19 custom actions, as suggested in the LaunchCondition documentation. This is used with an error message in the Error table describing the error, and the CA itself is conditioned on the property values.

PhilDW
  • 20,260
  • 1
  • 18
  • 28