Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX detect .Net 4.0.3

Tags:

wix

wix3.7

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?

like image 931
Sean Airey Avatar asked Sep 23 '13 17:09

Sean Airey


People also ask

Does WiX support .NET 6?

NET 6 runtime is installed. WiX provides pre-defined properties to check this for .

How do I know if I have WiX toolset installed?

The best way to check if you have WiX Toolset installed is by opening up the Command Prompt and trying to execute the light.exe command. You can also check in the Programs and Features section of Control Panel.

What is WiX C#?

Introduction. Wix# is an open Source framework available on GitHub and used for generating Installer using C# syntax. Wix# is an open source framework for building installer setup for MSI source code by using script file that is written into C#. Wix# uses C# to produce a wix or MSI source code.


2 Answers

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

like image 111
Sean Airey Avatar answered Sep 24 '22 21:09

Sean Airey


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)"
like image 45
igolaizola Avatar answered Sep 26 '22 21:09

igolaizola