问题
Thanks to Andrei's answer here:
Install .NET Framework 4.7.2 (if needed) with WIX installer
I check to see if .NETFramework 4.7.2 is installed and install it. I have one slight problem remaining though... My main app has a post install action that launches the app. One can't launch the app until 4.7.2 has been installed AND the system has been rebooted. I could simply remove this post install action code from my apps installer, but it would be nice if it did launch the app if 4.7.2 was already installed and there is no reason to reboot.
How can I "see" into my Bootstrapper project from my apps installer and see if .NET Framework was just installed or not? I could then conditionally run the post install action. If 4.7.2 was just installed, I believe it will put up a prompt asking for a reboot which is perfect.
Suggestions on other ways to handle the problem are welcome. I suppose another way to handle things would be to force a reboot after the .NET installation and after the reboot install my app. But I think it would be better to install everything and then reboot. I would think this is a very common problem but I haven't found anything addressing it. Perhaps it's too easy a problem! I'm new to WIX and not clear how to share variables and information from one project to another. Especially getting bootstrapper info from the main app installer. Let me know if I can provide clarification or more details.
Thanks!
The post install action looks like:
<CustomAction Id="PostInstallAction"
Return="check"
Execute="immediate"
BinaryKey="MyAppInstaller.CustomActions.CA.dll"
DllEntry="PostInstallAction" />
<InstallExecuteSequence>
<Custom Action="PreInstallAction" Before="InstallValidate" />
<Custom Action="PostInstallAction" After="InstallFinalize" />
</InstallExecuteSequence>
// follow function abbreviated (no logging and try/catch).In file customactions.cs
public static ActionResult PostInstallAction(Session session)
{
if (!Process.GetProcessesByName(MyAppLauncherFileName).Any())
Process.Start(ConfigurationManager.AppSettings[MyAppLauncherExePath]);
return ActionResult.Success;
}
FOLLOW UP: It would also be nice if the reboot which is required to install 4.7.2, happened automatically, rather than prompting the user. Is there a way to do that, or is that hard coded into the 4.7.2. web installer?
回答1:
Regarding checking if .NET 4.6.1 or higher is installed or not you can add this:
<PropertyRef Id="WIX_IS_NETFRAMEWORK_461_OR_LATER_INSTALLED" />
<Condition Message="$(var.ProductName) requires .NET Framework 4.6.1 or
higher.">
<![CDATA[Installed OR WIX_IS_NETFRAMEWORK_461_OR_LATER_INSTALLED]]>
</Condition>
Regarding the reboot, you can use the Supress property from ForceReboot action. You can consult the next urls for that:
http://wixtoolset.org/documentation/manual/v3/xsd/wix/forcereboot.html
https://docs.microsoft.com/en-us/windows/desktop/Msi/reboot
https://docs.microsoft.com/en-us/windows/desktop/Msi/forcereboot-action
来源:https://stackoverflow.com/questions/53744486/require-wix-bootstrapper-to-reboot-after-net-framework-installation-and-skip-ap