0

my requirement is to check the latest .net runtime version in client machine so that i can compare weather the particular version is belong to .net 6 runtimes or not ,i have tried some few steps to achieve my requirement

<util:RegistrySearch Id="DotNetVersionSearch" Variable="DOTNETVERSION"
                     Root="HKLM"
                     Key="SOFTWARE\Wow6432Node\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.WindowsDesktop.App"
                     Value="Version"
                     Result="value" />

the paricular variable I have declared on top of fragement <Property Id="DOTNETVERSION" Secure="yes" />

and I have define one custom action to verify weather the .net runtime version is belong to .net 6 or not like below .

 <CustomAction  Id="CheckDotNetVersion"
                BinaryKey="CustomActionBinary"
                DllEntry="CheckDotNetVersion"
                Execute="immediate"
                Return="check" />

and the action i have defined in a class named as Customaction.cs

    [CustomAction]
    public static ActionResult CheckDotNetVersion(Session session)
    {
        string dotNetVersion = session["DotNetVersion"];
        string dotNetVersionMin = session["DotNetVersionMin"];

        Version version;
        Version versionMin;

        if (!Version.TryParse(dotNetVersion, out version))
        {
            session.Log("Failed to parse DotNetVersion.");
            return ActionResult.Failure;
        }

        if (!Version.TryParse(dotNetVersionMin, out versionMin))
        {
            session.Log("Failed to parse DotNetVersionMin.");
            return ActionResult.Failure;
        }

        int result = version.CompareTo(versionMin);

        session["WIX_DOTNET_VERSION_COMPARE"] = result.ToString();

        return ActionResult.Success;
    }

and for displaying the error I have used the bal:Condition tag like below

<bal:Condition
        Message="This setup requires Microsoft .NET 6.0 or above."
        ><![CDATA[Installed OR (NOT Installed AND WIX_DOTNET_VERSION_COMPARE >= 0)]]>
    </bal:Condition>

but this is not working , can somebody help me on this to fix the issue

1 Answer 1

3

Wix has a built-in support for .NET version check, you can use that:

https://wixtoolset.org/docs/tools/wixext/dotnet/#net-and-net-core

Wix 3.x does not seem to support .NET 6 detection out of the box (but I am not completely sure), but Wix 4 does, so you may need to upgrade.

To figure out what is not working with your code, you can run your installer with a log file (msiexec yourfile.msi /l*v log.txt), and check the values of your variables passed around in the log after run.

Other than that, not quite sure why you are using <bal:Condition>, it is for "bal", the bootstrapper (a program that runs before your installation starts). Custom actions are executed during the installation, not in a bootstrapper. So, there is no chance for this condition to work, as far as I can see?

Sign up to request clarification or add additional context in comments.

10 Comments

HI @Nikolay, could you please suggest any way for detecting a .net 6 version of client machine using the wix 3.x(and is it possible to check the client .net 6 version in bootstrapper without using of this custom action) , because WiX 4 is not fully backward compatible with WiX 3.x so it difficult to predict all the custom action of my current setup will work there or not
It looks like there is a similar question: stackoverflow.com/questions/72518411/…. They recommend either use Wix4 directly, or use the method that is used by Wix4 (use the NetCoreCheck.exe)
Hi @Nikolay , i went through the link that you suggested , so as per the link its good to port the wix v3.11 into wix v4 so could you please guide me how to port it , i mean the initial steps , which wix.exe to install and which visual studio extension to use or and tool is available to port it immediately ,
There is automatic conversion tool I guess? wixtoolset.org/docs/fourthree
Hello @Nikolay , thank for the suggestion i am able to use the convert command , but after converting it to wix v4 while building I am getting the below error error CNDL0199: The Wix element has an incorrect namespace of 'wixtoolset.org/schemas/v4/wxs'. Please make the Wix element look like the following: <Wix xmlns="schemas.microsoft.com/wix/2006/wi">. i have followed this link github.com/wixtoolset/issues/issues/5967 but couldn't get a satisficed answer , could you please help me on this
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.