diff --git a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs index e6f85ca78..d3ae833d5 100644 --- a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs +++ b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs @@ -301,6 +301,13 @@ public async Task TryStartAsync(HostStartOptions startOptions, Cancellatio _pipelineThread.Start(); + if (startOptions.InitialWorkingDirectory is not null) + { + _logger.LogDebug($"Setting InitialWorkingDirectory to {startOptions.InitialWorkingDirectory}..."); + await SetInitialWorkingDirectoryAsync(startOptions.InitialWorkingDirectory, cancellationToken).ConfigureAwait(false); + _logger.LogDebug("InitialWorkingDirectory set!"); + } + if (startOptions.LoadProfiles) { _logger.LogDebug("Loading profiles..."); @@ -320,13 +327,6 @@ public async Task TryStartAsync(HostStartOptions startOptions, Cancellatio _logger.LogDebug("Shell integration not enabled!"); } - if (startOptions.InitialWorkingDirectory is not null) - { - _logger.LogDebug($"Setting InitialWorkingDirectory to {startOptions.InitialWorkingDirectory}..."); - await SetInitialWorkingDirectoryAsync(startOptions.InitialWorkingDirectory, cancellationToken).ConfigureAwait(false); - _logger.LogDebug("InitialWorkingDirectory set!"); - } - await _started.Task.ConfigureAwait(false); return true; }