The exit code is 0xe0434352, the "CCR" exception that is the unmanaged exception that triggers managed exception handling in a .NET program. You don't have a try/catch in your code and no event handler for AppDomain.CurrentDomain.UnhandledException so you have nothing to look at but the "it crashed" exit code.
This is otherwise normal for code you run in a pre/post-build event. Such code runs in a sandbox that tries to defeat the thing you are trying to do, anything that would cause the build to stall with a "press Enter to continue" style interaction. Pretty important, nobody likes a 30 hour build on a build server to grind to a halt on something like this. You can catch the exception, you'll get an InvalidOperationException:
Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read
Which is okay advice, your program will no longer crash. But will not stop either, Console.Read/Line() was of course defeated as well. This feature is pretty solid. I've needed to do this only one time and the only way I came up with was Thread.Sleep().
When you are in Rome, act like a Roman. Redirect or write output to a file so it can be read later, after the build is completed.