Skip to content

Instantly share code, notes, and snippets.

@geoder101
Forked from analogrelay/CommandLineException.cs
Created August 13, 2018 17:17
Show Gist options
  • Save geoder101/2fdd3351fc36d0988dbe408cb8c581c5 to your computer and use it in GitHub Desktop.
Save geoder101/2fdd3351fc36d0988dbe408cb8c581c5 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