How can I detect whether .NET Framework 3.5 or higher is installed in WiX? - wix

I currently using the following markup in my WiX installer project to check if .NET Framework 3.5 or greater is installed.

there is no Release Reg_DWORD for .Net Framework 3.5 But you can detect it using the following RegistrySearch:
<Property Id="NET35INSTALLED" Secure="yes" Admin="yes"/>
<util:RegistrySearch
Id="Net35Installed"
Variable="NET35INSTALLED"
Root="HKLM"
Key="Software\Microsoft\NET Framework Setup\NDP\v3.5"
Value="Install"
Win64="no"
Format="compatible"
/>
To use it in a condition use NET35INSTALLED = 1.
See more information in the official documentation.

Visit :
https://www.mking.net/blog/detecting-dotnet-framework-versions-with-wix
there you see the check for 4.7.2 installed :
<PropertyRef Id='WIXNETFX4RELEASEINSTALLED'/>
<Condition Message='This setup requires the .NET Framework 4.7.2 (or greater) to be installed.'>
<![CDATA[Installed OR (WIXNETFX4RELEASEINSTALLED >= "#461808")]]>
</Condition>
You only need to replace the release key with the 3.5 version..

Related

How to check for .net framework 4.7.1 with Wix 3.11

I am trying to check for .net Version with Wix 3.11 via Condition. This works fine until 4.5 like this:
<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>
Checking for anything above 4.5 seems not to be possible - at least not with this mechanism. How can I do that?
That method (PropertyRef) is syntactical sugar. The NetFxExtension preprocessor injects the implementation at compile time. WiX is currently lagging behind. The implementation you are looking for would be something like:
<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>
https://github.com/wixtoolset/issues/issues/5575
Update (hot33331): Added a # before the number 461308. Without that it did not work for me.

"MsiNTProductType", "POWERSHELLVERSION" in WIX 3.6

In my WIX project, I want to use Cited Properties.
The following Cited Properties work well
<PropertyRef Id="NETFRAMEWORK45"/>
<Condition Message="You must install .Net Framework 4.5">
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>
<PropertyRef Id="VersionNT64"/>
<Condition Message="This application cannot be running on 32 bit architechure">
<![CDATA[Installed OR VersionNT64]]>
</Condition>
But other Properties use my debug to filed with the following message:
"Error 1 Unresolved reference to symbol 'Property:MsiNTProductType' in section 'Product:*'"
for example:
BTW, the WixNetFxExtension exist.
MsiNTProductType is a valid built-in Windows Installer property, so this should work OK provided you haven't got any typos in the WIX code. As Phil asks, please update your question with the actual Wix code that references the MsiNTProductType property.
In my experience it is easy to mix up something trivial in a Wix source file, and the error is most likely just an extra comma, dot or some other trivial typo. I'll just include a link to the MSI Property Reference.
This is my properties section.
The only one that work is "NETFRAMEWORK45".
The rest of them in comment because they cuse the error I mention.
I must understand why the error occured.
Thanks,
Didi
<PropertyRef Id="NETFRAMEWORK45"/>
<Condition Message="You must install .Net Framework 4.5">
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>
<!--
<PropertyRef Id="POWERSHELLVERSION"/>
<Condition Message="You must install Powershell ver 3.0">
<![CDATA[Installed OR POWERSHELLVERSION >= "3.0"]]>
</Condition>
<PropertyRef Id="VersionNT64"/>
<Condition Message="This application cannot be running on 32 bit architechure">
<![CDATA[Installed OR VersionNT64]]>
</Condition>
<PropertyRef Id ="VersionNT"/>
<Condition Message="Operating system must be Windows Server 2008 or higher">
<![CDATA[VersionNT >= 600]]>
</Condition>
<PropertyRef Id ="MsiNTProductType"/>
<Condition Message="Operating system must be SERVER O.S">
<![CDATA[MsiNTProductType <> 3]]>
</Condition>
-->
MsiNTProductType is a standard Windows Installer property - you're trying to redefine it and getting that error. All you need for the standard properties is the condition - delete the PropertyRef for MsiNTProductType, VersionNT, VersionNT64.

Check 3rd party software version installed

I'm filling property with installed office version
<Property Id="VISIOVERSION">
<RegistrySearch Id="VisioVersion14x64"
Root="HKLM"
Key="SOFTWARE\Microsoft\Office\14.0\Visio"
Name="InstalledVersion"
Type="raw" Win64="yes" />
</Property>
How can I compare this version with a minimum version required? Versions look like 14.0.5432.3
If office version 14.0.5432.3 is minimum version required, try this condition.
<Condition Message="Minimum office version 14.0.5432.3 is required to continue the installation.">
(VISIOVERSION >= "14.0.5432.3")
</Condition>
A LaunchCondition should help out here. Checking that the prerequisite version is high enough is a simple >= operation. However, it is important to always include Installed in your LaunchConditions to ensure that your software can be uninstalled if the prerequisite was removed first. A full example:
<Condition Message="Viso v14.0.5432.3 or newer is required before installing [ProductName].">
Installed OR (VISIOVERSION >= "14.0.5432.3")
</Condition>

How can I check .NET framework 4.5 prerequestics in WiX

I'd like to validate both .NET framework 4.0 and 4.5 should be installed at server before proceeding a installation. Hence I used the following snippet, but I don't know about 4.5 validattion, which was not listed in the link Reference
<PropertyRef Id="NETFRAMEWORK40FULL"/>
<Condition Message='This setup requires Microsoft .NET Framework 4.0 Full package or greater needs to be installed for this installation to continue.'>
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
</Condition>
The NETFRAMEWORK45 property can be used the same as the NETFRAMEWORK40FULL. Note there is no "client" or "full" framework for The .NET Framework v4.5. There is just one. So the following code should do what you want:
<PropertyRef Id="NETFRAMEWORK40FULL"/>
<PropertyRef Id="NETFRAMEWORK45"/>
<Condition Message='This setup requires Microsoft .NET Framework 4.0 Full package or greater needs to be installed for this installation to continue.'>
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
</Condition>
<Condition Message='This setup requires Microsoft .NET Framework 4.5 package or greater needs to be installed for this installation to continue.'>
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>
Note that .NET Framework v4.5 is an in place upgrade of .NET Framework 4.0 so checking for both could get you into a situation where you'll never satisfy both conditions. You might want to just check that .NET Framework v4.0 or .NET Framework v4.5 is installed. That condition would look more like:
<Condition Message='This setup requires Microsoft .NET Framework 4.0 Full or 4.5 package or greater needs to be installed for this installation to continue.'>
<![CDATA[Installed OR NETFRAMEWORK40FULL OR NETFRAMEWORK45]]>
</Condition>

How to intelligently install .NET 4.x using WiX Burn

When installing an application that can use either .NET 4.0 or 4.5, what is the best practice when installing the prerequisites .NET framework? And how do you implement it using Burn in WiX?
These are the options and trade-offs that I am aware of:
Option 1: Install .NET 4.0 (just what you need)
Advantages: None known (except for Windows XP, where this is the only choice)
Option 2: Install .NET 4.5 if .NET 4.5 is not present
Advantages: User won't have to install .NET 4.5 later for future
apps. App won't experience a .NET version change when user later does
upgrade to .NET 4.5. App immediately gets performance improvements of
.NET 4.5.
Option 3: Install .NET 4.5 only if neither .NET 4.x is present
Advantages: Much faster deployment than option 2 if .NET 4.0 is
already installed. If it's not, then the advantages of option 2
apply.
As far as I can tell, the best practice would be option 2 if the performance improvements are important and option 3 if average deployment speed is important. Does this sound right? Am I missing any advantage to option 1? Most importantly, if option 3 does make sense, how do you implement it using Burn when installing .NET from the web?
Below is how I detect .NET in my bundle. Note the use of DetectConditions and InstallConditions. The DetectCondition will check whether or not the specific package is installed, whereas the InstallCondition can be used to override the DetectCondition to specify when the package should be installed. For example, on XP you can't install .NET 4.5 so my InstallCondition prevents installation in such a case.
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4FullVersion" />
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4x64FullVersion" Win64="yes" />
<!-- .NET 4.5 only installed if Vista or higher AND it's not already installed-->
<PackageGroup Id="Netfx45">
<ExePackage Id="Netfx45" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes" InstallCommand="/q"
SourceFile="C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX45Full\dotnetfx45_full_x86_x64.exe"
DetectCondition="(Netfx4FullVersion="4.5.50709") AND (NOT VersionNT64 OR (Netfx4x64FullVersion="4.5.50709"))"
InstallCondition="(VersionNT >= v6.0 OR VersionNT64 >= v6.0) AND (NOT (Netfx4FullVersion="4.5.50709" OR Netfx4x64FullVersion="4.5.50709"))"/>
</PackageGroup>
<!-- .NET 4.0 only installed if XP AND it's not already installed -->
<PackageGroup Id="Netfx4Full">
<ExePackage Id="Netfx4Full" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes" InstallCommand="/q"
SourceFile="C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40\dotNetFx40_Full_x86_x64.exe"
DetectCondition="Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)"
InstallCondition="(VersionNT < v6.0 OR VersionNT64 < v6.0) AND (NOT (Netfx4FullVersion OR Netfx4x64FullVersion))"/>
</PackageGroup>
Then if you want to install one of the packages, just reference it in your chain:
<Chain>
<PackageGroupRef Id='Netfx45'/>
</Chain>
With regards to your specific question, I would install whatever framework version the application was tested against. If tested against both .NET 4.0 and .NET 4.5 I suppose it is a judgement call, however I would try to simplify the setup experience as much as possible. So if .NET 4.0 were already installed and the application does not require .NET 4.5, I would not install it.
Also, there is a disadvantage to Option 2 if you are using a custom Managed Bootstrapper Application. Let's say you have .NET 4.0 installed and your managed bootstrapper requires .NET 4.0 (or greater). When you run the installer it will install .NET 4.5 which replaces .NET 4.0, forcing your installer to reboot halfway through because it was using .NET framework at the same time it was being updated. Again, this is only an issue if you are using your own custom managed bootstrapper.