Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@geoffappleford
Forked from analogrelay/CommandLineException.cs
Created August 14, 2018 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geoffappleford/88a39491f682bea3531a4254f295fd28 to your computer and use it in GitHub Desktop.
Save geoffappleford/88a39491f682bea3531a4254f295fd28 to your computer and use it in GitHub Desktop.
Easy way to debug command-line apps
private static int Main(string[] args)
{
#if DEBUG
if (args.Any(a => a == "--debug"))
{
args = args.Where(a => a != "--debug").ToArray();
Console.WriteLine($"Ready for debugger to attach. Process ID: {Process.GetCurrentProcess().Id}.");
Console.WriteLine("Press ENTER to continue.");
Console.ReadLine();
}
#endif
// The rest of the code...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment