public InstallService ( Action |
||
beforeInstall | Action |
|
afterInstall | Action |
|
beforeRollback | Action |
|
afterRollback | Action |
|
Résultat | void |
public void InstallService( InstallHostSettings settings, Action<InstallHostSettings> beforeInstall, Action afterInstall, Action beforeRollback, Action afterRollback) { using (var installer = new SpHostServiceInstaller(settings, _hostConfigurator)) { Action<InstallEventArgs> before = x => { beforeInstall?.Invoke(settings); }; Action<InstallEventArgs> after = x => { afterInstall?.Invoke(); }; Action<InstallEventArgs> before2 = x => { beforeRollback?.Invoke(); }; Action<InstallEventArgs> after2 = x => { afterRollback?.Invoke(); }; installer.InstallService(before, after, before2, after2); } }
public void InstallService( InstallHostSettings settings, Action <InstallHostSettings> beforeInstall, Action afterInstall, Action beforeRollback, Action afterRollback) { using (var installer = new SpHostServiceInstaller(settings, _hostConfigurator)) { Action <InstallEventArgs> before = x => { beforeInstall?.Invoke(settings); }; Action <InstallEventArgs> after = x => { afterInstall?.Invoke(); }; Action <InstallEventArgs> before2 = x => { beforeRollback?.Invoke(); }; Action <InstallEventArgs> after2 = x => { afterRollback?.Invoke(); }; installer.InstallService(before, after, before2, after2); } }
public void InstallService( InstallHostSettings settings, Action <InstallHostSettings> beforeInstall, Action afterInstall, Action beforeRollback, Action afterRollback) { using (var installer = new SpHostServiceInstaller(settings, _hostConfigurator)) { Action <InstallEventArgs> before = x => { if (beforeInstall != null) { beforeInstall(settings); installer.ServiceProcessInstaller.Username = settings.Credentials.Username; installer.ServiceProcessInstaller.Account = settings.Credentials.Account; bool gMSA = false; // Group Managed Service Account (gMSA) workaround per // https://connect.microsoft.com/VisualStudio/feedback/details/795196/service-process-installer-should-support-virtual-service-accounts if (settings.Credentials.Account == ServiceAccount.User && settings.Credentials.Username != null && ((gMSA = settings.Credentials.Username.EndsWith("$", StringComparison.InvariantCulture)) || string.Equals(settings.Credentials.Username, "NT SERVICE\\" + settings.ServiceName, StringComparison.InvariantCulture))) { _log.InfoFormat(gMSA ? "Installing as gMSA {0}." : "Installing as virtual service account", settings.Credentials.Username); installer.ServiceProcessInstaller.Password = null; installer.ServiceProcessInstaller .GetType() .GetField("haveLoginInfo", BindingFlags.Instance | BindingFlags.NonPublic) .SetValue(installer.ServiceProcessInstaller, true); } else { installer.ServiceProcessInstaller.Password = settings.Credentials.Password; } } }; Action <InstallEventArgs> after = x => { if (afterInstall != null) { afterInstall(); } }; Action <InstallEventArgs> before2 = x => { if (beforeRollback != null) { beforeRollback(); } }; Action <InstallEventArgs> after2 = x => { if (afterRollback != null) { afterRollback(); } }; installer.InstallService(before, after, before2, after2); } }