-
-
Save geoder101/2fdd3351fc36d0988dbe408cb8c581c5 to your computer and use it in GitHub Desktop.
Easy way to debug command-line apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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