WiX installer - how can I check for .net framework 3.5 and 4.6 with Wix 3.10 - wix

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"

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.

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.

Related

In WiX, what's the correct way to enable .NET 3.5?

I'm creating an installer for a Windows desktop app, which has a dependency on another product that requires .NET 3.5
When installing this on Windows 10, .NET 3.5 is included and has to be enabled in Add/Remove Windows Features. I don't think it is valid to install a downloadable version of .NET 3.5 on Windows 10 (correct me if I'm wrong!).
So, is there a way to get WiX to enable the .NET 3.5 "feature" rather than downloading and installing it?
Not sure whether this is the correct way but you can try a custom action with the following command
dism.exe /online /enable-feature /featurename:NetFx3
You can get a list of all available features by dism /online /get-features if you want to try other windows features.
There is a way to install .NET 3.5 on Windows 10 and the latest Windows Server: to update a group policy value that will allow to download .NET 3.5 (blog post).
...open the command prompt and type "gpedit". The "Local Computer Policy Editor" opens where we can locate the necessary setting under the "Computer Configuration" > "Administrative Templates" > "System". On the left side, under "Settings", we can find a setting named "Specify settings for optional component installation and component repair"
This is what we are going to modify. Let's open it and check "Enabled" and then check the second option – "Download repair content and optional features directly from Windows Update instead of Windows Server Update Services (WSUS)" and click "OK":
Now, if we retry adding the .NET Framework 3.5, we can see that it succeeds...
I personally then revert this policy setting to its original value, if it was different.
WiX Samples: Some potentially helpful links in general:
WiX Quick Start Suggestions (with sample links).
https://helgeklein.com/blog/2014/09/real-world-example-wix-msi-application-installer/
Alternative Tools: Maybe keep in mind that commercial tools have features that are easier to use to get your product out there quickly. WiX is great though.
MSI Tools (comparing different MSI tools)
On WiX, setup GUI and Commercial tools
Prerequisites: I would suggest you add a LaunchCondition to the package to abort installation if the .NET framework is not there. You can bundle the .NET framework with your application, but I really do not recommend that: Outdated prerequisites in packages.
LaunchCondition: The concept of LaunchConditions checks for a certain condition to be true before installation is allowed to continue:
Check if prerequisites are installed before installing a windows installer package (please check this link at the very least - if you don't check other links)
An earlier answer on LaunchConditions.
Quick, inline sample:
<Condition Message="The .NET Framework 2.0 must be installed">
Installed OR NETFRAMEWORK20
</Condition>
WiX and .NET Framework: Some built-in measures to detect the .NET framwork.
How To: Check for .NET Framework Versions (official WiX documentation)
How to check for .net framework 4.7.1 with Wix 3.11
How can I detect whether .NET Framework 4.6.1 or higher is installed in WiX?
Link:
Wix IIS Version check launch condition not working
LaunchConditions and missing runtimes

How to download and install the .NET Framework using Wix Installer?

We have an Application that depends on an installed .NET Framework 4.5. The Wix setup should automatically detect when an .NET Framework 4.5 (or greater) is not installed. That works fine with the following wix declaration:
<PropertyRef Id="NETFRAMEWORK45"/>
<Condition Message=".NET Framwork 4.5 is not installed.">
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>
Our Target: The Wix Setup should automatically download and install the .Net Framework 4.5. It seem, that 'burn' provides a mechanism, that let the setup install the .NET Framwork automatically: http://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/install_dotnet.html. The documentation defines references to Setup files of the .NET Framework:
<MsiPackage Id="MyApplication" SourceFile="$(var.MyApplicationSetup.TargetPath)"/>
But we not want to add the .NET Framework into our Setup. The setup should automatically download it on the target system where the setup will be executed.
How can we achieve this?
Please see the NetFx45Web package group ref:
http://wixtoolset.org/documentation/manual/v3/customactions/wixnetfxextension.html
For more information on how this works if you didn't have the package group ref see a similar example:
Web download of vcruntime140 with wix burn
Microsoft allows you to redistribute their framework but only in its original form.
This also means that you can't build the framework into your own .msi package.
What you can do is to provide a separate bootstrap installer, Setup.exe, that looks for the installed framework and starts your .NET Framework redistributable.
If you have found a way to do this without using a Bootstrap installer, please let me know.

Check for .net framework 4.5.2 in registry in wix

How can I check for .net framework 4.5.2 in registry using wix. I've tried this
<Property Id="WIX_IS_NETFRAMEWORK_452_OR_LATER_INSTALLED"/>
<Condition
Message="This application requires .NET Framework 4.5.2. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR WIX_IS_NETFRAMEWORK_452_OR_LATER_INSTALLED]]>
</Condition
but it is not working. I am using wix v3.10
Finally after trial and error I managed to solved the issue using
<Condition
Message="This application requires .NET Framework 4.5.2. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK45>="#379893"]]>
</Condition>
The condition returns a DWORD which will be prefixed with a # sign
and the condition should be
<![CDATA[Installed OR NETFRAMEWORK45>="#379893"]]>
The value 379893 is the Value of the release DWORD. More information can be found from this Microsoft site
EDIT: fixed typo.
Try to add a PropertyRef element that has an ID of WIX_IS_NETFRAMEWORK_452_OR_LATER_INSTALLED
<PropertyRef Id='WIX_IS_NETFRAMEWORK_452_OR_LATER_INSTALLED' />

Using wix, how to install Dot net framework 4.5 for Windows 7/8 and dot net 4.0 from Xp and vista

I want to install Dot net framework 4.5 as a prerequisite for my application wherever it is possible.As minimum OS requirement for dot net framework 4.5 is Windows Vista SP2.I would like to install dot net framework 4.5 on OS on or above Windows Vista SP2 and Dot net framework 4.0 below Windows Vista Sp2 (i.e. Windows Xp machine). I am using below code.
<PropertyRef Id="NETFRAMEWORK40FULL" />
<PropertyRef Id="NETFRAMEWORK45" />
<Condition Message="This application requires .NET Framework 4.0 Full or .NETFramework 4.5. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK40FULL OR NETFRAMEWORK45]]>
</Condition>
<Chain>
<PackageGroupRef Id="NetFx40Web" />
<PackageGroupRef Id="NetFx45Web" />
<PackageGroupRef Id="SqlServer2008R2" />
</Chain>
But it is giving error as
The Windows Installer XML variable 'WixMbaPrereqPackageId' is declared in morethan one location.
The Windows Installer XML variable 'WixMbaPrereqLicenseUrl' is declared in more than one location.
I think We can not install both DotnetFramework4 and DotnetFramework 4.5 using WixNetFxExtension library. What choices to do i have now to implement it?? Should i have to manually write a PackageGroup to install Dot net Framework 4.5 checking the OS version is compatible to install it.
Wix has documentation for installing the .Net framework with your applications using Burn.
http://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/install_dotnet.html

Check for .NET 4.5 full install - which property?

How do I check for a full .net 4.5 install?
http://wix.sourceforge.net/manual-wix3/wixnetfxextension.htm
has a list of all properties but stops at 4.0.
The open issues list has a nice Topic "add documentation for the new properties" which helne to USE them.
Anyone knows the property Name for a full 4.5 install?
Answering myself - as documentation was updated also:
NETFRAMEWORK45
More concrete:
<PropertyRef Id="NETFRAMEWORK45"/>
<Condition Message="This application requires .NET Framework 4.5. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>