Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 683ab4e

Browse files
authored
Fix ServiceController tests (#26208)
* Fix incorrect log name calculation; clear log on start, as before * Redundant exists check
1 parent baf4a44 commit 683ab4e

File tree

1 file changed

+4
-2
lines changed
  • src/System.ServiceProcess.ServiceController/tests/System.ServiceProcess.ServiceController.TestService

1 file changed

+4
-2
lines changed

src/System.ServiceProcess.ServiceController/tests/System.ServiceProcess.ServiceController.TestService/TestService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public TestService(string serviceName)
3333

3434
public static string GetLogPath(string serviceName)
3535
{
36-
return Assembly.GetEntryAssembly().Location + "." + serviceName + ".log";
37-
}
36+
return typeof(TestService).Assembly.Location + "." + serviceName + ".log";
37+
}
3838

3939
protected override void OnContinue()
4040
{
@@ -74,6 +74,8 @@ protected override void OnShutdown()
7474

7575
protected override void OnStart(string[] args)
7676
{
77+
File.Delete(GetLogPath(ServiceName));
78+
7779
WriteLog(nameof(OnStart) + " args=" + string.Join(",", args));
7880
base.OnStart(args);
7981
}

0 commit comments

Comments
 (0)