diff --git a/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs b/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs index 2c88782..5f5c885 100644 --- a/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs +++ b/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs @@ -17,6 +17,8 @@ public static class ServiceRunner where SERVICE : IMicroService { public static int Run(Action> runAction) { + Directory.SetCurrentDirectory(PlatformServices.Default.Application.ApplicationBasePath); + var innerConfig = new HostConfiguration(); innerConfig.Action = ActionEnum.RunInteractive; innerConfig.Name = typeof(SERVICE).FullName; @@ -269,7 +271,6 @@ private static void StartService(HostConfiguration config, ServiceContr { if (!(sc.Status == ServiceControllerStatus.StartPending | sc.Status == ServiceControllerStatus.Running)) { - Directory.SetCurrentDirectory(PlatformServices.Default.Application.ApplicationBasePath); sc.Start(); sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromMilliseconds(1000)); Console.WriteLine($@"Successfully started service ""{config.Name}"" (""{config.Description}"")");