Creating a WiX setup project for an AddIn targeting .Net 4.5.2 adds a prerequisite for .Net Framework 2 (instead of 4.5)

Add-in Express™ Support Service
That's what is more important than anything else

Creating a WiX setup project for an AddIn targeting .Net 4.5.2 adds a prerequisite for .Net Framework 2 (instead of 4.5)
 
Simon Fisher




Posts: 17
Joined: 2016-07-12
Hi,

We have an AddIn solution with multiple projects that all target .Net 4.5.2. We're using Visual Studio 2019 and the WiX framework for our setup projects. When I use the Add-In Express context menu to 'Create Setup Project', the project that is created always includes a prerequisite check for .Net Framework 2.

As an example, in the setup project it creates, the Product.wxs file contains this:

<!-- The ".NET Framework" launch condition. -->
<PropertyRef Id="NETFRAMEWORK20"/>
<Condition Message="This setup requires the .NET Framework 2.0.  Please install the .NET Framework and run this setup again."><![CDATA[Installed OR NETFRAMEWORK20]]></Condition>


If I create a brand new Add-In Express project, by default it targets .Net 4.5. If I create a setup project using the same steps, that project has a check for .Net 4.5. In Product.wxs:
<PropertyRef Id="NETFRAMEWORK45"/>
.

As soon as I change that same project to target 4.5.2 instead, and create a new setup project, it checks for 2.0 again.

I appreciate that I can manually change those checks after the setup project is created, but it would be nice if the setup project creator handled this properly.

Is this something that can be fixed? Or do you have any guidance as to what versions of the .Net framework are supported?

Regards,

Simon
Posted 16 Aug, 2020 20:30:09 Top
Andrei Smolin


Add-in Express team


Posts: 17360
Joined: 2006-05-11
Hello Simon,

WiX 3.11 supports .NET up to version 4.5. To work around this, you should change the code. Here's an example from https://stackoverflow.com/questions/49778581/how-to-check-for-net-framework-4-7-1-with-wix-3-11; the example checks for .NET 4.7.1.

<PropertyRef Id="NETFRAMEWORK45" />
<Condition Message="This application requires .NET Framework 4.7.1. Please install the .NET Framework then run this installer again."><![CDATA[Installed OR NETFRAMEWORK45>=#461308]]>
</Condition>


The magic number above and all such numbers (including that for 4.5.2) can be found at https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 Aug, 2020 01:27:17 Top
Simon Fisher




Posts: 17
Joined: 2016-07-12
Thank you Andrei, I didn't think that it could be an issue with WiX.

I did a bit of research and I've come up with a slightly different solution. Even though WiX won't auto-detect the correct .NET version, it still has constants for them:


<PropertyRef Id="WIX_IS_NETFRAMEWORK_452_OR_LATER_INSTALLED"/>
<Condition Message="This setup requires the .NET Framework 4.5.2.  Please install the .NET Framework and run this setup again."><![CDATA[Installed OR WIX_IS_NETFRAMEWORK_452_OR_LATER_INSTALLED]]></Condition>


On a machine with .NET 4.7.1 installed (only), my installer runs properly. I've yet to test it on a machine with only 4.5, or even 2.0, but I'm confident.

Reference: https://wixtoolset.org/documentation/manual/v3/customactions/wixnetfxextension.html
Posted 17 Aug, 2020 17:06:56 Top
Andrei Smolin


Add-in Express team


Posts: 17360
Joined: 2006-05-11
Thank you, Simon!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Aug, 2020 11:21:48 Top