I am trying to code our bundle installer to only install the prerequisite .NET 6.0.3 if the machine doesn't have .NET 6.0.3 or newer already installed, I would like to skip the .NET install if 6.0.3 (or newer) is present. The DetectCondition ALWAYS returns false though, no matter what I try. I'm using WiX 3.11.
I'm wondering is if the registry key I'm looking at will work for the comparison in the DetectCondition. Other than that I can't think of why DetectCondition always returns false, even if I set it directly to "true" or switch the >= to a <.
The registry key is there and the value on my machine currently is 6.0.8. This is what has me wondering if the Registry node type isn't correct for this type of comparison? If that's the case I don't know if what I'm trying to do is possible..
This is in our .net wxs file for the bundle installer:
<Fragment>
<!-- Detect the version of .NET -->
<!-- Check the registry and compare it to the version in the PackageGroup below -->
<util:RegistrySearch Variable ="DOT_NET_VER"
Id="DotNetVerFind"
Root="HKLM"
Key="SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedhost"
Value="Version"
Result="value" />
<PackageGroup Id="Net6">
<!-- Install .NET 6.0 -->
<ExePackage Id="Netfx60"
DisplayName="Microsoft .NET 6.0 Desktop Runtime (v6.0.3)"
Cache="yes" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes" InstallCommand="/norestart /quiet"
SourceFile="Prerequisites\windowsdesktop-runtime-6.0.3-win-x64.exe"
DetectCondition="DOT_NET_VER >= v6.0.3" bal:PrereqSupportPackage="yes">
<ExitCode Value="0" Behavior="success"/>
<ExitCode Behavior="scheduleReboot"/>
</ExePackage>
</PackageGroup>
</Fragment>
The bundle is 32-bit, so it will check the 32-bit registry by default (SOFTWARE\WOW6432Node\dotnet\...
). You have to put Win64='yes'
to search the 64-bit registry. If you looked at the log in %TMP%, you'd probably see that the variable was never set.
I don't think that registry key will tell you whether the Windows desktop .NET Core is installed, just the core runtime (maybe, my testing a few years ago showed that some installers didn't write this key at all). In v4, you will be able to get the latest version of .NET 6 Windows desktop by using:
<netfx:DotNetCoreSearch RuntimeType="desktop" Platform="x64" MajorVersion="6" Variable="DOT_NET_VER" />