Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing 2 Services in the same installer results in both services using the last ServiceControl definition #541

Closed
jonreis opened this issue Dec 3, 2018 · 1 comment

Comments

@jonreis
Copy link
Contributor

jonreis commented Dec 3, 2018

I have the following code which creates 2 Windows Services

      // Create the Service element for Connexion.Gateway service
      var service = installDir.Files.FirstOrDefault(f => string.Compare(f.Id, "Connexion.Gateway.exe", StringComparison.OrdinalIgnoreCase) == 0);
      if (service == null)
        throw new Exception("Could not locate Connexion.Gateway.exe");
      var serviceInstaller = CreateService("Connexion.Gateway", "Connexion Gateway Service");
      serviceInstaller.StartOn.Start = null; //set it to null if you don't want service to start as during deployment
      service.ServiceInstaller = serviceInstaller;

      // Create Alerting Service
      var alertingService = installDir.Files.FirstOrDefault(f => string.Compare(f.Id, "Connexion.Gateway.Alerting.exe", StringComparison.OrdinalIgnoreCase) == 0);
      if (alertingService == null)
        throw new Exception("Could not locate Connexion.Gateway.Alerting.exe");
      var alertingServiceInstaller = CreateService("Connexion.Gateway.Alerting", "Connexion Gateway Alerting Service");
      alertingServiceInstaller.StartOn.Start = null; //set it to null if you don't want service to start as during deployment
      alertingService.ServiceInstaller = alertingServiceInstaller;

This results in the both services end up with the same ServiceControl. It appears that WixSharp is using the last set ServiceControl for both Services. This is new to the latest version of WixSharp (v1.9.3)

        <ServiceControl Id="StopConnexion.Gateway.Alerting" Name="Connexion.Gateway.Alerting" Stop="both" Wait="yes" />
        <ServiceControl Id="StartConnexion.Gateway.Alerting" Name="Connexion.Gateway.Alerting" Wait="no" />
        <ServiceControl Id="RemoveConnexion.Gateway.Alerting" Name="Connexion.Gateway.Alerting" Remove="uninstall" Wait="yes" />



      <Component Id="Component.Connexion.Gateway.exe" Guid="42a9532c-f568-4b73-9469-8a03898769e1">
        <File Id="Connexion.Gateway.exe" Source="Connexion.Gateway\bin\Debug\Connexion.Gateway.exe">
          <NativeImage Id="NativeImage" Platform="64bit" Priority="3" AssemblyApplication="[INSTALLDIR]\Connexion.Gateway.exe" xmlns="http://schemas.microsoft.com/wix/NetFxExtension" />
        </File>

        <ServiceInstall Id="Connexion.Gateway" Name="Connexion.Gateway" DisplayName="Connexion.Gateway" Description="Connexion Gateway Service" Type="ownProcess" Start="auto" ErrorControl="normal" Account="[WIX_ACCOUNT_LOCALSERVICE]" Interactive="no">
          <ServiceConfig DelayedAutoStart="yes" PreShutdownDelay="60000" ServiceSid="none" OnInstall="yes" OnReinstall="no" OnUninstall="no" />

          <util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="restart" RebootMessage="Failure actions do not specify reboot" ResetPeriodInDays="1" RestartServiceDelayInSeconds="30" />
        </ServiceInstall>

        <ServiceControl Id="StopConnexion.Gateway.Alerting" Name="Connexion.Gateway.Alerting" Stop="both" Wait="yes" />
        <ServiceControl Id="StartConnexion.Gateway.Alerting" Name="Connexion.Gateway.Alerting" Wait="no" />
        <ServiceControl Id="RemoveConnexion.Gateway.Alerting" Name="Connexion.Gateway.Alerting" Remove="uninstall" Wait="yes" />
      </Component>


      <Component Id="Component.Connexion.Gateway.Alerting.exe" Guid="42a9532c-f568-4b73-9469-8a03ce702d83">
        <File Id="Connexion.Gateway.Alerting.exe" Source="Connexion.Gateway.Alerting\bin\Debug\Connexion.Gateway.Alerting.exe">
          <NativeImage Id="NativeImage.2" Platform="64bit" Priority="3" AssemblyApplication="[INSTALLDIR]\Connexion.Gateway.exe" xmlns="http://schemas.microsoft.com/wix/NetFxExtension" />
        </File>

        <ServiceInstall Id="Connexion.Gateway.Alerting" Name="Connexion.Gateway.Alerting" DisplayName="Connexion.Gateway.Alerting" Description="Connexion Gateway Alerting Service" Type="ownProcess" Start="auto" ErrorControl="normal" Account="[WIX_ACCOUNT_LOCALSERVICE]" Interactive="no">
          <ServiceConfig DelayedAutoStart="yes" PreShutdownDelay="60000" ServiceSid="none" OnInstall="yes" OnReinstall="no" OnUninstall="no" />

          <util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="restart" RebootMessage="Failure actions do not specify reboot" ResetPeriodInDays="1" RestartServiceDelayInSeconds="30" />
        </ServiceInstall>

        <ServiceControl Id="StopConnexion.Gateway.Alerting" Name="Connexion.Gateway.Alerting" Stop="both" Wait="yes" />
        <ServiceControl Id="StartConnexion.Gateway.Alerting" Name="Connexion.Gateway.Alerting" Wait="no" />
        <ServiceControl Id="RemoveConnexion.Gateway.Alerting" Name="Connexion.Gateway.Alerting" Remove="uninstall" Wait="yes" />
      </Component>
@oleg-shilo oleg-shilo added the bug label Dec 5, 2018
oleg-shilo pushed a commit that referenced this issue Dec 5, 2018
…both services using the last ServiceControl definition
@oleg-shilo
Copy link
Owner

Fixed.
The fix will be available in the next release.

oleg-shilo added a commit that referenced this issue Jan 18, 2019
- Issue #541: Installing 2 Services in the same installer results in …
oleg-shilo pushed a commit that referenced this issue Jan 19, 2019
* VS project templates - added packages.config files
* Added Condition-s for .NET Frameworks 4.7.1 and 4.7.2
* Issue #569: Updating WixSharp leads to malfuncion of SetEvVar
* Added support for `UI.Error` WiX element
* Issue #552: Question: Install 2 windows services in same installer
* Issue #541: Installing 2 Services in the same installer results in …
* Samples update
* Issue #560: Semantic difference between UninstallCondition and IsUninstalling
* Issue #564: Correct variable name of SequentialGuid initialization.
* Issue #562: Typo in Compiler.cs comments
* Issue #561: Typo in WixProject.cs
* Added missing namespace in custom dialog template, fixed comment.
* Added explicit `WixEntity.ComponentId` property
* Issue #551: Cannot include extra .wxs as part of a bundle
* Issue #542: ServiceInstaller.StartOn/StopOn/RemoveOn - Documentation bug
* Issue #544: Failed while processing WebSites; added support for `IISVirtualDir.AttributesDefinition`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants