1
votes

I have a requirement to permit a WiX installer to install the product only if Framework 4.6 is installed. If this is not the case I display an error message to the user.

This is working fine, but now I must verify that if there is a previous version running in framework 3.5, I must let the user know that Framework 4.6 is required. Somehow my approach is not working. Would appreciate a little help. This is the code I am using in WiX:

  <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 WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED]]>
  </Condition>

  <PropertyRef Id="NETFRAMEWORK35" />
  <Condition Message="This application requires .NET Framework 4.6. Please install the .NET Framework then run this installer again.">
    <![CDATA[(NETFRAMEWORK35 AND NOT WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED)]]>
  </Condition>

And in the CustomAction.config I have:

<startup useLegacyV2RuntimeActivationPolicy="true">           
      <supportedRuntime version="v4.0" />
      <supportedRuntime version="v2.0.50727"/>
</startup>

UPDATE

Changed the Launch Condition to:

  <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>

But all the installer does is just display the familiar "Setup Wizard ended prematurely"

2
Hmm, I would disable all custom actions as a first step and recompile and test, and / or enable verbose logging to determine what is failing. I always like to suggest to setup developers to enable automatic logging (you may already have done so) by using the procedure found under "Globally for all setups on a machine" in the linked content. Then there will always be a log available in the %TEMP% folder when you need it. Sort by modify to find the latest log.Stein Åsmul
Good idea...will try...D. Bermudez

2 Answers

0
votes

There may be something I don't understand about your scenario, but wouldn't the first condition cater for both cases? All you need is for .NET 4.6 to be installed? That second condition now appears to be true only when 3.5 is installed and 4.6 is not installed. So I assume the setup won't launch if both versions are installed - and I am not sure if those versions can co-exist? I can never keep track of what .NET versions can be installed at the same time, and what CLR they share. The 3.5 version came with Windows 7 I think? Some details.

I don't see any custom action WiX markup in your question, so I can't really say anything about that CustomAction.config. Managed code custom actions are not my specialty.

0
votes

Your both launch conditions are countering one another.

One is allowing installation if .Net framework 4.6 or higher is found. Other is allowing installation only if .Net Framework 3.5 is found and .Net Framework 4.6 is not found.

Your second condition does not have "Installed OR" property, which makes sure uninstall does not fail because of Launch Condition.

Custom Action Config only affects custom action project, your launch conditions are not affected by it .

Edit: Unless your Launch Condition is using some property created by user defined custom action.