问题
We have two installation modes: service and app.
Using Wix#, I couldn't find a way to present this simple two-radio buttons dialog to the user:
Choose your installation:
(*) App [default]
( ) Service
And then choose which files (and action) to deploy/perform accordingly.
How do we even bind the user's decision with the actual operation?
Edit:
I discovered how to do that, eventually, but still can't make the GUI selection affect the deployed files (although the bound property do change). Here is the new, more detailed question:
Property seems to change per user's selection, but conditioned files are not being deployed
回答1:
Note: I don't use Wix#.
Service Installation
Same Executable?: Just to be sure, is this the same executable that can run as an app and a service? (I actually made an application capable of doing that once, didn't work too well).
Service Installation: The installation as a service is generally done via built-in MSI constructs (I believe you know this already, this is just for reference and completeness):
- ServiceControl Element (MSI table) and ServiceInstall Element (MSI table) - does all the work reliably if used right
- How to install and start a Windows Service using WiX - previous answer
- How to create a Windows Service MSI Installer Using WiX - (untested WiX markup)
- Also see Chris Painter's IsWiX Tutorials.
Custom Actions: Many people use custom actions to install services. This is generally an MSI anti-pattern (unnecessary, prone to errors, etc...). I believe you would need custom actions to install a service only in some cases - like you propose - unless the binary you refer to are two different files. The custom action(s) would need to register and then start the service. You must also set the boot behavior for the service.
Alternatives?
Assuming the binary is a single binary and not two different ones:
Two MSIs: Is it acceptable to compile two MSI files to do the two different tasks? You would have one MSI to install the service version and one to install the the application version? Install one or the other, make sure installation destinations are different (so MSIs reference counting does not interfere - this also allows the MSIs to be installed both at the same time). You could use a setup.exe bundle to install either one?
Full Monty: I suppose you could install two copies of the binary at the same time, and register one as a service. Then you would need to ask the user to start the service or not? And that would be a custom action to set whether the service will launch automatically on boot or be started manually or right away etc...? Or, could you register and run as a service always and allow the application to be run interactively too? Threading?
回答2:
Installation modes
You can make it by features. Feature has fixed files list, formatted before MSI build. If you adds Service and Application features you can countrol what's files to add in destination folder.
By default your files are in Complete feature name, so you need to add anothers. Here is feature example:
Feature examples
Please add your ones and set what to deploy with ADDLOCAL parameter. Just set it on radiobutton click:
session["ADDLOCAL"]="Feature1,Feature2,"
Warrning: when you will do update you need to set previous features names.
GUI installation flow
If i need to make some splitted forms flow i just adds 2 sequences of my dialogs in row and use my JumpTo method for ManagedForm:
/// <summary>
/// Переход к форме определенного типа.
/// </summary>
/// <param name="dialogType">Тип формы.</param>
public bool JumpTo(Type dialogType)
{
int index = Shell.Dialogs.IndexOf(dialogType);
if (index < 0)
{
return false;
}
BeginInvoke(new Action(() => Shell.GoTo(index)));
return true;
}
After, i need to control behavior for first and last one forms for jump to correct dialog.
来源:https://stackoverflow.com/questions/57942206/wix-how-to-bind-custom-ui-decision-to-actual-installation-steps