Dobra, znalazłem workaround, ale imo brzydki:
Main:
static void Main(string[] args)
{
if (args.Length != 1)
return;
var serviceA = new ServiceA();
var serviceB = new ServiceB();
ServiceBase serviceToRun = null;
if (args[0] == serviceA.ServiceName)
{
serviceToRun = serviceA;
}
else if (args[0] == serviceB.ServiceName)
{
serviceToRun = serviceB;
}
else
{
return;
}
ServiceBase.Run(serviceToRun);
}
W każdym installerze nadpisałem metodę OnAfterInstall:
protected override void OnAfterInstall(IDictionary savedState)
{
base.OnAfterInstall(savedState);
using (var svc = new ServiceController(serviceInstaller.ServiceName))
{
string path = Context.Parameters["assemblypath"].Trim(' ', '\'', '"');
string pathWithArgs = String.Format("\"{0}\" {1}", path, serviceInstaller.ServiceName);
ChangeServiceConfig(svc.ServiceHandle, -1, -1, -1, pathWithArgs, null, IntPtr.Zero, null, null, null, null);
}
}
No i oczywiście PInvoke:
[DllImport("advapi32.dll", EntryPoint = "ChangeServiceConfigW", ExactSpelling = true,
CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int ChangeServiceConfig(SafeHandle hService, int nServiceType, int nStartType,
int nErrorControl,
String lpBinaryPathName, String lpLoadOrderGroup,
IntPtr lpdwTagId, [In] String lpDependencies,
String lpServiceStartName,
String lpPassword, String lpDisplayName);
Jak ktoś ma lepszy pomysł to niech da znać ;)