andre.silva-wdg
Posts: 11
Joined: Mon Dec 14, 2020 6:10 pm

Problems with setting .net framework 4.8 as mandatory prerequisite.

Tue Jun 01, 2021 3:39 pm

Hello, I configured .Net Framework 4.8 as a mandatory prerequisite, so that the user does not have the possibility to uncheck the option.
When I try to install the product for the first time, it is identified that the machine does not have the requirement and the installation is done.
After some time processing an error message is displayed saying the requirement was not installed correctly!
I close the install and try to install again and the requirement appears as installed.
Would you like to know the reason for this?

Problem occurs in:
VM Windows Server 2016 Standard

Catalin
Posts: 6509
Joined: Wed Jun 13, 2018 7:49 am

Re: Problems with setting .net framework 4.8 as mandatory prerequisite.

Fri Jun 04, 2021 4:16 pm

Hello Andre,

After the .NET installation, are you restarting the machine?

Please note that, by default, .NET Framework requires a reboot after its' installation.

As you may already know, there are two checks that we are doing for prerequisites:

- one check before the prerequisite is installed --> its' condition must be false => the prerequisite will be installed

- once after the prerequisite is installed --> its' condition must be true => the prerequisite was correctly installed

In your case:
I configured .Net Framework 4.8 as a mandatory prerequisite
by mandatory I believe you have unchecked the "Continue with main installation even if the prerequisite was not installed" option.

In this case, the second check is done (if the option is uncheched, the second check is not done).

In the case of .NET Framework prerequisite, the check is done through a registry search. If I'm not mistaken, the registry is updated only after a reboot, in case of a .NET Framework installation.

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

andre.silva-wdg
Posts: 11
Joined: Mon Dec 14, 2020 6:10 pm

Re: Problems with setting .net framework 4.8 as mandatory prerequisite.

Fri Jun 04, 2021 8:34 pm

Hello Catalin!
This even leaves the option "Continue with main installation even if the prerequisite was not installed" unchecked so that the requirement is mandatory otherwise my system will not work!
I figured that was it, that as soon as the error occurs and the installation is aborted, when I restart the machine and install again the prerequisite appears as installed.
There is no workaround for this?

Catalin
Posts: 6509
Joined: Wed Jun 13, 2018 7:49 am

Re: Problems with setting .net framework 4.8 as mandatory prerequisite.

Mon Jun 07, 2021 5:32 pm

Hello Andre,

Unfortunately, this is how the .NET Framework installer was developed (most prerequisites do not behave the same) and therefore not many workarounds are available.

A solution I can think of would be forcing a machine reboot right after the prerequisite was installed through the "Reboot system after installing this prerequisite" option set to "Always".

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

andre.silva-wdg
Posts: 11
Joined: Mon Dec 14, 2020 6:10 pm

Re: Problems with setting .net framework 4.8 as mandatory prerequisite.

Fri Sep 03, 2021 1:47 pm

Hi Catalin!
I adopted your suggestion, but now I encounter the following problem.
At the end of the installation I leave it as an option for the user to restart the machine. Each time he does this, the machine boots up and the installation runs again :cry: , even after the installation completes successfully!
Is there any way this doesn't happen?

Catalin
Posts: 6509
Joined: Wed Jun 13, 2018 7:49 am

Re: Problems with setting .net framework 4.8 as mandatory prerequisite.

Mon Sep 06, 2021 2:49 pm

Hello Andre,

This might be happening due to the "Reboot system after installing this prerequisite" option.

When this option is used, a scheduled task is created whose purpose is to resume the installation after the reboot.

This is why the reboot should be done after installing the prerequisite, not at the end of the installation.
At the end of the installation I leave it as an option for the user to restart the machine.
Could you please give me some more details about this so I can further investigate it? Normally, the reboot prompt should happen after the installation of the prerequisite. Considering it is a pre-install prerequisite, this should happen long before the end of the installation.

With that being said, could you please let me know how did you postpone the reboot prompt towards the end of the installation?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

andre.silva-wdg
Posts: 11
Joined: Mon Dec 14, 2020 6:10 pm

Re: Problems with setting .net framework 4.8 as mandatory prerequisite.

Mon Sep 06, 2021 3:12 pm

The reboot is being performed correctly after installing .net framework 4.8 and when I log into the computer the installation continues.
The problem is right after that, when I finish the installation and leave the option to restart the computer checked, when I log in the installation starts again. As the installation was successful it is not necessary to open the installation again.

Catalin
Posts: 6509
Joined: Wed Jun 13, 2018 7:49 am

Re: Problems with setting .net framework 4.8 as mandatory prerequisite.

Tue Sep 14, 2021 1:24 pm

Hello Andre,

First of all, please accept my apologies for the delayed reply.

I have indeed mananged to reproduce this on my end as well using the current scenario.

Unfortunately, I can not say for sure why this is happening.

I will need some more time to further investigate this and I will followup on this thread as soon as I will have more information.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Catalin
Posts: 6509
Joined: Wed Jun 13, 2018 7:49 am

Re: Problems with setting .net framework 4.8 as mandatory prerequisite.

Tue Sep 14, 2021 4:10 pm

Hello Andre,

As promised, here is my followup after further investigating this.

It looks like I was indeed right about the reason why this is happening.

Basically, the scheduled task that is created to restart the setup after the reboot is not removed in due time (it is removed after the user presses on the "Finish" button).

The solution to this would be to add a little bit of delay to the reboot action.

Unfortunately, the only way to achieve this would be through another custom action, since you can not add a delay to the "Set property" custom action.

The custom action should also be able to run asynchronously (the setup should not wait for it).

In the end, here is what I've came up with: a small .EXE that display a messagebox and then proceed to perform the reboot through the "shutdown.exe" OS tool. The easiest way of doing this would have been through a script, but unfortunately script custom actions can not be run asynchronously.

The .EXE can be written in any language you want. I will provide in the following lines how I have created one in C#, perhaps that will help you:

Code: Select all

namespace RebootMachine
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initialize the variables we pass to the MessageBox.Show method
            string caption = "Reboot the machine";
            string message = "Are you sure you want to reboot the machine?";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            MessageBoxIcon icon = MessageBoxIcon.Question;
            
            DialogResult result;

            result = MessageBox.Show(message, caption, buttons, icon);

            if (result == DialogResult.Yes)
            {

                System.Diagnostics.Process.Start("shutdown.exe", "/r /t 5 /c \" \"");

            }

        }
    }
}
As you can see, we run the "shutdown.exe" tool that comes by default with any Windows OS. The parameters we pass mean:

/r --> shutdown and then restart

/t 5 --> wait 5 seconds before rebooting (the delay we discussed earlier)

/c " " --> usually, a prompt will appear stating that "This machine will be rebooted in less than a minute" or something similar depending on the time we've set. We use this parameter to avoid that.

Now, to implement this in Advanced Installer, add the .EXE in the "Files and Folders" page. After doing so, add a "Launch File" custom action, without sequence that launches the .EXE. For this custom aciton, uncheck the "Wait for custom action to finish before proceeding" & "Wait for return code at the end of the sequence" options.

Proceed as before by scheduling the custom action as a "Published Event" and conditioning it based on the checkbox selection.

Hope this will help!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”