oleg-shilo / wixsharp

Framework for building a complete MSI or WiX source code by using script files written with C# syntax.
MIT License
1.1k stars 174 forks source link

.NET framework requisite for net48 (in installer and managed UI) #1426

Closed thenextman closed 8 months ago

thenextman commented 8 months ago

A two part question (and some of this might relate more to WiX itself than wixsharp, so my apologies if this is not the correct avenue).

  1. .NET 4.8 is a prerequisite for my installed product. I add the proper version check to the project:
project.SetNetFxPrerequisite(Condition.Net48_Installed, "You don't have net48");

And see it reflected in the wxs:

<Condition Message="You don't have net48"><![CDATA[ (NETFRAMEWORK45 >= "#528040") ]]></Condition>

However, running the installer on my Windows 11 machine triggers the condition "You don't have net48". I definitely do: although it doesn't show up in add/remove programs, I develop and run software all day that requires net48. Just to validate, running the .NET 4.8 web installer tells me ".NET Framework 4.8 or a later update is already installed on this computer.".

So what am I doing wrong?

  1. I want to use .NET 4.8 features in my managed UI and custom actions. I'm happy that the installer won't run on systems without .NET 4.8 installed. I've retargeted my managed project to .NET Framework 4.8 and everything builds fine; but I note the installer still launches on a system without .NET 4.8.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
    </startup>
</configuration>

and setting it with project.CAConfigFile. But now I don't get any managed UI: the installer immediately shows the UAC prompt, which I acknowledge, but then nothing happens (the installer just goes away).

Thank you!!

oleg-shilo commented 8 months ago

Hi Richard,

I also found it difficult to deal with the very static nature of WiX functionality. You are right. It is the question about WiX, so I will be guessing only.

app.config has no relevance for the situation. CAConfigFile is not involved in the detection but the initialization of MSI CLR hosting runtime.

Some of the WiX extensions is either failing to perform the detection test on Win11 or the detection algorithm is not working in that conditions. So the extension leaves NETFRAMEWORK45 incorrectly set.

You can try and see what is the value of NETFRAMEWORK45 property at runtime and it can give you some clues.

But, me personally, I had so many situations when I had to cause WiX wisdom for months for some very simple task, so I always prefer to take the matter in my hands.

I would do the check as from the CA. IE, check the presence of some files, and registry (BTW this is what WiX extensions do). and then either abort the installation or set your own property to some meaningful value.

YOu can even set that NETFRAMEWORK45 if WiX fails to do so. But you will need to do it as soon as before launch condition. Project.Load can be a good candidate for that.

thenextman commented 8 months ago

Thank you @oleg-shilo, it's what I thought. Rather than mess with this anymore I will just use some custom code to detect the prerequisite. wixsharp is the best for making that so easy!