jabbera / my-vsts-tasks

20 stars 18 forks source link

Install service ignores exceptions #45

Open marcselis opened 5 years ago

marcselis commented 5 years ago

The install service task is marked as successful even if the underlying TopShelf executable threw an exception while installing the service.

MattDavisRM commented 5 years ago

@marcselis Are you deploying using a deployment group?

marcselis commented 5 years ago

@MattDavisRM, no we are deploying on a remote server using WinRM.

andymerts commented 4 years ago

I'm using version 8 of the Install Topshelf Service and targeting a deployment group and encountering exactly the same behavior.

The "Got something other then Ok from Topshelf" is from my startup code, and it is returning the integer value of AbnormalExit from my Main function. Invoking the install command via a command line task fails appropriately in this situation. I'm using the latest version of the Topshelf NuGet package in my project (v3.2.0).

Logs: 2020-06-19T17:11:43.6013432Z ##[section]Starting: Install a Topshelf Service: <<path_to_exe>> 2020-06-19T17:11:43.6360927Z ============================================================================== 2020-06-19T17:11:43.6361004Z Task : Install Topshelf Service 2020-06-19T17:11:43.6361050Z Description : Installs a TopShelf service using the standard command line options for Topshelf 4.0. 2020-06-19T17:11:43.6361086Z Version : 8.0.0 2020-06-19T17:11:43.6361116Z Author : Michael Barry 2020-06-19T17:11:43.6361162Z Help : [More Information](https://github.com/jabbera/my-vsts-tasks) 2020-06-19T17:11:43.6361198Z ============================================================================== 2020-06-19T17:11:44.6380252Z Installing TopShelf service: <<path_to_exe>> with instanceName: . 2020-06-19T17:11:44.6658031Z CMD: $env:DT_DISABLEINITIALLOGGING='true' 2020-06-19T17:11:44.6658338Z $env:DT_LOGLEVELCON='NONE' 2020-06-19T17:11:44.6658538Z & "<<path_to_exe>>" uninstall -username "<<user name>>" -password:"***" 2020-06-19T17:11:44.6659009Z & "<<path_to_exe>>" install -username "<<user name>>" -password:"***" 2020-06-19T17:11:44.6659111Z 2020-06-19T17:11:45.3425301Z Got something other than Ok from Topshelf: AbnormalExit 2020-06-19T17:11:45.3425490Z Topshelf.HostFactory Error: 0 : An exception occurred creating the host, Topshelf.HostConfigurationException: The service was not properly configured: 2020-06-19T17:11:45.3435455Z [Failure] Command Line An unknown command-line option was found: DEFINE: username = 2020-06-19T17:11:45.3509016Z [Failure] Command Line An unknown command-line option was found: ARGUMENT: <<user name>> 2020-06-19T17:11:45.3565515Z [Failure] Command Line An unknown command-line option was found: DEFINE: password = *** 2020-06-19T17:11:45.3601414Z [Success] Name <<service name>> 2020-06-19T17:11:45.3601629Z [Success] ServiceName <<service name>> 2020-06-19T17:11:45.3622797Z at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results) 2020-06-19T17:11:45.3627113Z at Topshelf.HostFactory.New(Action`1 configureCallback) 2020-06-19T17:11:45.3627754Z Topshelf.HostFactory Error: 0 : The service terminated abnormally, Topshelf.HostConfigurationException: The service was not properly configured: 2020-06-19T17:11:45.3634006Z [Failure] Command Line An unknown command-line option was found: DEFINE: username = 2020-06-19T17:11:45.3634589Z [Failure] Command Line An unknown command-line option was found: ARGUMENT: <<user name>> 2020-06-19T17:11:45.3638742Z [Failure] Command Line An unknown command-line option was found: DEFINE: password = *** 2020-06-19T17:11:45.3645527Z [Success] Name <<service name>> 2020-06-19T17:11:45.3645614Z [Success] ServiceName <<service name>> 2020-06-19T17:11:45.3645685Z at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results) 2020-06-19T17:11:45.3645752Z at Topshelf.HostFactory.New(Action`1 configureCallback) 2020-06-19T17:11:45.3645793Z at Topshelf.HostFactory.Run(Action`1 configureCallback) 2020-06-19T17:11:46.0102159Z Topshelf.HostFactory Error: 0 : An exception occurred creating the host, Topshelf.HostConfigurationException: The service was not properly configured: 2020-06-19T17:11:46.0102303Z [Failure] Command Line An unknown command-line option was found: DEFINE: username = 2020-06-19T17:11:46.0102380Z [Failure] Command Line An unknown command-line option was found: ARGUMENT: <<user name>> 2020-06-19T17:11:46.0102518Z [Failure] Command Line An unknown command-line option was found: DEFINE: password = *** 2020-06-19T17:11:46.0103393Z [Success] Name <<service name>> 2020-06-19T17:11:46.0103439Z [Success] ServiceName <<service name>> 2020-06-19T17:11:46.0103511Z at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results) 2020-06-19T17:11:46.0103567Z at Topshelf.HostFactory.New(Action`1 configureCallback) 2020-06-19T17:11:46.0107536Z Topshelf.HostFactory Error: 0 : The service terminated abnormally, Topshelf.HostConfigurationException: The service was not properly configured: 2020-06-19T17:11:46.0107628Z [Failure] Command Line An unknown command-line option was found: DEFINE: username = 2020-06-19T17:11:46.0107679Z [Failure] Command Line An unknown command-line option was found: ARGUMENT: <<user name>> 2020-06-19T17:11:46.0107787Z [Failure] Command Line An unknown command-line option was found: DEFINE: password = *** 2020-06-19T17:11:46.0107838Z [Success] Name <<service name>> 2020-06-19T17:11:46.0107884Z [Success] ServiceName <<service name>> 2020-06-19T17:11:46.0107956Z at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results) 2020-06-19T17:11:46.0109379Z at Topshelf.HostFactory.New(Action`1 configureCallback) 2020-06-19T17:11:46.0109446Z at Topshelf.HostFactory.Run(Action`1 configureCallback) 2020-06-19T17:11:46.0109558Z Got something other than Ok from Topshelf: AbnormalExit 2020-06-19T17:11:46.0512042Z ##[section]Finishing: Install a Topshelf Service: <<path_to_exe>>

davislabs commented 4 years ago

@andymerts You might look at #43 , I haven't looking into it close to two years, but I couldn't get a resolution and ended up not using this for targeting deployment groups.