diff --git a/CliFx/ApplicationConfiguration.cs b/CliFx/ApplicationConfiguration.cs
index 243f268..7a7e7cd 100644
--- a/CliFx/ApplicationConfiguration.cs
+++ b/CliFx/ApplicationConfiguration.cs
@@ -17,22 +17,30 @@ namespace CliFx
/// Whether debug mode is allowed in this application.
///
public bool IsDebugModeAllowed { get; }
-
+
///
/// Whether preview mode is allowed in this application.
///
public bool IsPreviewModeAllowed { get; }
+ ///
+ /// Prompt debugger launch when application is in debug mode
+ ///
+ public bool PromptDebuggerLaunchInDebugMode { get; }
+
///
/// Initializes an instance of .
///
public ApplicationConfiguration(
IReadOnlyList commandTypes,
- bool isDebugModeAllowed, bool isPreviewModeAllowed)
+ bool isDebugModeAllowed,
+ bool isPreviewModeAllowed,
+ bool promptDebuggerLaunchInDebugMode)
{
CommandTypes = commandTypes;
IsDebugModeAllowed = isDebugModeAllowed;
IsPreviewModeAllowed = isPreviewModeAllowed;
+ PromptDebuggerLaunchInDebugMode = promptDebuggerLaunchInDebugMode;
}
}
}
\ No newline at end of file
diff --git a/CliFx/CliApplication.cs b/CliFx/CliApplication.cs
index 6dff82d..d8c84b7 100644
--- a/CliFx/CliApplication.cs
+++ b/CliFx/CliApplication.cs
@@ -125,8 +125,19 @@ namespace CliFx
// Debug mode
if (_configuration.IsDebugModeAllowed && input.IsDebugDirectiveSpecified)
{
- // Ensure debugger is attached and continue
- await WaitForDebuggerAsync();
+ if (_configuration.PromptDebuggerLaunchInDebugMode)
+ {
+ // Prompt debugger launcher dialog
+ if (!Debugger.IsAttached)
+ {
+ Debugger.Launch();
+ }
+ }
+ else
+ {
+ // Ensure debugger is attached and continue
+ await WaitForDebuggerAsync();
+ }
}
// Preview mode
diff --git a/CliFx/CliApplicationBuilder.cs b/CliFx/CliApplicationBuilder.cs
index 9c6724b..0405576 100644
--- a/CliFx/CliApplicationBuilder.cs
+++ b/CliFx/CliApplicationBuilder.cs
@@ -16,6 +16,7 @@ namespace CliFx
private readonly HashSet _commandTypes = new HashSet();
private bool _isDebugModeAllowed = true;
+ private bool _promptDebuggerLaunch = false;
private bool _isPreviewModeAllowed = true;
private string? _title;
private string? _executableName;
@@ -78,9 +79,10 @@ namespace CliFx
///
/// Specifies whether debug mode (enabled with [debug] directive) is allowed in the application.
///
- public CliApplicationBuilder AllowDebugMode(bool isAllowed = true)
+ public CliApplicationBuilder AllowDebugMode(bool isAllowed = true, bool promptDebuggerLaunch = false)
{
_isDebugModeAllowed = isAllowed;
+ _promptDebuggerLaunch = promptDebuggerLaunch;
return this;
}
@@ -166,7 +168,7 @@ namespace CliFx
_typeActivator ??= new DefaultTypeActivator();
var metadata = new ApplicationMetadata(_title, _executableName, _versionText, _description);
- var configuration = new ApplicationConfiguration(_commandTypes.ToArray(), _isDebugModeAllowed, _isPreviewModeAllowed);
+ var configuration = new ApplicationConfiguration(_commandTypes.ToArray(), _isDebugModeAllowed, _isPreviewModeAllowed, _promptDebuggerLaunch);
return new CliApplication(metadata, configuration, _console, _typeActivator);
}