@@ -39,33 +39,44 @@ public StartEditorServicesCommand()
39
39
Environment . SetEnvironmentVariable ( "POWERSHELL_DISTRIBUTION_CHANNEL" , "PSES" ) ;
40
40
_disposableResources = new List < IDisposable > ( ) ;
41
41
_loggerUnsubscribers = new List < IDisposable > ( ) ;
42
+
43
+ // These are the actual defaults. Because of how PowerShell cmdlets work, the "defaults"
44
+ // in the corresponding .PS1 file don't matter (though they match for discoverability),
45
+ // nor can these be set at the field declaration because the engine resets parameters to
46
+ // null on invocation.
47
+ HostName = "PSES" ;
48
+ HostProfileId = "PSES" ;
49
+ HostVersion = new Version ( 0 , 0 , 0 ) ;
50
+ SessionDetailsPath = "PowerShellEditorServices.json" ;
51
+ LogPath = "PowerShellEditorServices.log" ;
52
+ LogLevel = PsesLogLevel . Normal ;
42
53
}
43
54
44
55
/// <summary>
45
56
/// The name of the EditorServices host to report.
46
57
/// </summary>
47
- [ Parameter ( Mandatory = true ) ]
58
+ [ Parameter ]
48
59
[ ValidateNotNullOrEmpty ]
49
60
public string HostName { get ; set ; }
50
61
51
62
/// <summary>
52
63
/// The ID to give to the host's profile.
53
64
/// </summary>
54
- [ Parameter ( Mandatory = true ) ]
65
+ [ Parameter ]
55
66
[ ValidateNotNullOrEmpty ]
56
67
public string HostProfileId { get ; set ; }
57
68
58
69
/// <summary>
59
70
/// The version to report for the host.
60
71
/// </summary>
61
- [ Parameter ( Mandatory = true ) ]
72
+ [ Parameter ]
62
73
[ ValidateNotNullOrEmpty ]
63
74
public Version HostVersion { get ; set ; }
64
75
65
76
/// <summary>
66
77
/// Path to the session file to create on startup or startup failure.
67
78
/// </summary>
68
- [ Parameter ( Mandatory = true ) ]
79
+ [ Parameter ]
69
80
[ ValidateNotNullOrEmpty ]
70
81
public string SessionDetailsPath { get ; set ; }
71
82
@@ -118,7 +129,7 @@ public StartEditorServicesCommand()
118
129
/// <summary>
119
130
/// The path to where PowerShellEditorServices and its bundled modules are.
120
131
/// </summary>
121
- [ Parameter ]
132
+ [ Parameter ( Mandatory = true ) ]
122
133
[ ValidateNotNullOrEmpty ]
123
134
public string BundledModulesPath { get ; set ; }
124
135
@@ -133,7 +144,7 @@ public StartEditorServicesCommand()
133
144
/// The minimum log level that should be emitted.
134
145
/// </summary>
135
146
[ Parameter ]
136
- public PsesLogLevel LogLevel { get ; set ; } = PsesLogLevel . Normal ;
147
+ public PsesLogLevel LogLevel { get ; set ; }
137
148
138
149
/// <summary>
139
150
/// Paths to additional PowerShell modules to be imported at startup.
@@ -287,9 +298,12 @@ private void StartLogging()
287
298
288
299
private string GetLogDirPath ( )
289
300
{
290
- string logDir = ! string . IsNullOrEmpty ( LogPath )
291
- ? Path . GetDirectoryName ( LogPath )
292
- : Path . GetDirectoryName ( Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ) ;
301
+ string logDir = Path . GetDirectoryName ( LogPath ) ;
302
+ if ( string . IsNullOrEmpty ( logDir ) )
303
+ {
304
+ logDir = Directory . GetCurrentDirectory ( ) ;
305
+ // Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
306
+ }
293
307
294
308
// Ensure logDir exists
295
309
Directory . CreateDirectory ( logDir ) ;
0 commit comments