@@ -17,29 +17,6 @@ class Program
17
17
[ STAThread ]
18
18
static void Main ( string [ ] args )
19
19
{
20
- #if DEBUG
21
- // In the future, a more robust argument parser will be added here
22
- bool waitForDebugger =
23
- args . Any (
24
- arg =>
25
- string . Equals (
26
- arg ,
27
- "/waitForDebugger" ,
28
- StringComparison . InvariantCultureIgnoreCase ) ) ;
29
-
30
- // Should we wait for the debugger before starting?
31
- if ( waitForDebugger )
32
- {
33
- // Wait for 15 seconds and then continue
34
- int waitCountdown = 15 ;
35
- while ( ! Debugger . IsAttached && waitCountdown > 0 )
36
- {
37
- Thread . Sleep ( 1000 ) ;
38
- waitCountdown -- ;
39
- }
40
- }
41
- #endif
42
-
43
20
string logPath = null ;
44
21
string logPathArgument =
45
22
args . FirstOrDefault (
@@ -80,6 +57,43 @@ static void Main(string[] args)
80
57
// TODO: Set the level based on command line parameter
81
58
Logger . Initialize ( logPath , LogLevel . Verbose ) ;
82
59
60
+ #if DEBUG
61
+ bool waitForDebugger =
62
+ args . Any (
63
+ arg =>
64
+ string . Equals (
65
+ arg ,
66
+ "/waitForDebugger" ,
67
+ StringComparison . InvariantCultureIgnoreCase ) ) ;
68
+
69
+ // Should we wait for the debugger before starting?
70
+ if ( waitForDebugger )
71
+ {
72
+ Logger . Write ( LogLevel . Normal , "Waiting for debugger to attach before continuing..." ) ;
73
+
74
+ // Wait for 15 seconds and then continue
75
+ int waitCountdown = 15 ;
76
+ while ( ! Debugger . IsAttached && waitCountdown > 0 )
77
+ {
78
+ Thread . Sleep ( 1000 ) ;
79
+ waitCountdown -- ;
80
+ }
81
+
82
+ if ( Debugger . IsAttached )
83
+ {
84
+ Logger . Write (
85
+ LogLevel . Normal ,
86
+ "Debugger attached, continuing startup sequence" ) ;
87
+ }
88
+ else if ( waitCountdown == 0 )
89
+ {
90
+ Logger . Write (
91
+ LogLevel . Normal ,
92
+ "Timed out while waiting for debugger to attach, continuing startup sequence" ) ;
93
+ }
94
+ }
95
+ #endif
96
+
83
97
Logger . Write ( LogLevel . Normal , "PowerShell Editor Services Host starting..." ) ;
84
98
85
99
// Start the server
0 commit comments