Question

I have an application that requires .Net 4.0.3 (link).

I've found this article which tells me where I would find the version of .Net which is installed but all I can find is the list of included properties that the WiX compiler recognises (here).

I've tried following the directions in this article, which tells me to use the following code, but this just installs .Net 4 without the update:

<PropertyRef Id="NETFRAMEWORK40FULL"/>

<Condition Message="This application requires .NET Framework 4.0.3. Please install the .NET Framework then run this installer again.">
    <![CDATA[Installed OR NETFRAMEWORK40FULL]]>
</Condition>

How would I go about making WiX check for the specific 4.0.3 update, either through a pre-defined WiX property or checking the registry value myself?

Was it helpful?

Solution

After some reading, I ended up adding a bundle project to my solution that references my main Product in the standard WiX installer project (MyProject.Installer). I then used a RegistrySearch to find the version of the full .Net 4 installation.

<Bundle ....>
    <Chain>
        <PackageGroupRef Id="Netfx4Full" />
        <PackageGroupRef Id="Netfx403Update" />
        <MsiPackage Id="MyMsi" SourceFile="$(var.MyProject.Installer.TargetPath)" Compressed="yes" DisplayInternalUI="yes" />
    </Chain>
</Bundle>
<Fragment>
    <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" />
    <PackageGroup Id="Netfx4Full">
        <ExePackage Id="Netfx4Full"
              Cache="no"
              Compressed="yes"
              PerMachine="yes"
              Permanent="yes"
              Vital="yes"
              SourceFile="$(var.ProjectDir)dotNetFx40_Full_x86_x64.exe"
              DownloadUrl="http://go.microsoft.com/fwlink/?LinkId=164193"
              DetectCondition="Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)" />
    </PackageGroup>

    <PackageGroup Id="Netfx403Update">
        <ExePackage Id="Netfx403Update"
              Cache="no"
              Compressed="yes"
              PerMachine="yes"
              Permanent="yes"
              Vital="yes"
              SourceFile="$(var.ProjectDir)NDP40-KB2600211-x86-x64.exe" 
              DetectCondition="Netfx4FullVersion AND (Netfx4FullVersion &lt;&lt; &quot;4.0.3&quot; OR Netfx4FullVersion &lt;&lt; &quot;4.5&quot;)" />
    </PackageGroup>
</Fragment>

The condition expands out to Netfx4FullVersion AND (Netfx4FullVersion << "4.0.3" OR Netfx4FullVersion << "4.5") without XML escaping.

The following articles were helpful:

Bundle skeleton code

Bundle package manifest

Defining searches using WiX variables

Chaining packages into a bundle

How to check for .Net versions

OTHER TIPS

Version value within the registry key "SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" will be always 4.0.30319 for .net 4.0 (even if updates have been installed).

Here is the code I have used in my bundle to search if the .net 4.0.3 version was already installed:

<util:RegistrySearch Root="HKLM" 
    Key="SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.0.3"
    Result="exists" 
    Variable="Netfx403" />
<util:RegistrySearch Root="HKLM"  
    Key="SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.0.3" 
    Result="exists"
    Variable="Netfx403x64"
    Win64="yes" />

Then in your ExePackage DetectCondition:

DetectCondition="Netfx403 AND (NOT VersionNT64 OR Netfx403x64)"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top