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

Net472_Installed not detecting .NET Framework #736

Closed cocowalla closed 4 years ago

cocowalla commented 4 years ago

I'm using this to configure .NET Framework 4.7.2 as a prerequisite:

project.SetNetFxPrerequisite(Condition.Net472_Installed, "Please install .NET Framework 4.7.2 first: https://go.microsoft.com/fwlink/?LinkId=863262");

I have several versions of the .NET Framework installed, including 4.7.2 and 4.8, yet installation fails because of this prerequisite. Checking the registry, I see value 528040 for this value:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Release

AFAIK, this value is used by WiX to determine which version is installed, so I'm not sure what is going wrong here.

I also tried this, but get the same result:

project.SetNetFxPrerequisite("WIXNETFX4RELEASEINSTALLED >= #461808");

No idea if the root of this problem is in WixSharp, WiX, Windows Installer, or somewhere else :smile:

oleg-shilo commented 4 years ago

This is the code for Net472:

public readonly static Condition Net472_Installed = new Condition(" (NETFRAMEWORK45 >= '#461808') ");

This page provides the expected values.

If value 461808 is not what you want then you just define your own value as you did. Though the name of the WiX property still has to be NETFRAMEWORK45.

But I can be wrong... You will need to test it.

cocowalla commented 4 years ago

Yes, I'm using WixSharp's built-in Condition.Net472_Installed, which uses the condition (NETFRAMEWORK45 >= '#461808').

461808 is the correct version for .NET 4.7.2, but the problem is the prerequisite is failing, even though my Release key has value 528040, since I have .NET 4.8 installed. 528040 > 461808, so I don't understand why this is failing.

oleg-shilo commented 4 years ago

Your explanation makes sense. But I speculate that maybe NETFRAMEWORK45 (or WIXNETFX4RELEASEINSTALLED) is not set by WiX properly. Log it or MsgShow it and see if it is the case.

And of course you can read the regvalue by yourself: https://github.com/oleg-shilo/wixsharp/blob/67c57624b5bc3db389f35ee6dd540da33070409d/Source/src/WixSharp.Samples/Wix%23%20Samples/LaunchConditions/setup.cs.