lars
Explore posts from servers❔ Output to console if run from console - otherwise do not create console window?
I've got an Windows app that doesn't have a UI. I'd like to not have a console window opened when it's launched fron File Explorer, but if the user launches the app from a terminal (eg.
./myapp.exe
), then I'd want Console.WriteLine
calls (for debugging) to go to that terminal window. Is there some way to achieve this?
If I set the OutputType
to Exe
, then it spawns a console window when launched from File Explorer. However, when run from a terminal window, the behavior is correct - Console.WriteLine
output goes to that existing terminal window.
If I set the OutputType
to WinExe
, the behavior is correct when launched from File Explorer - no console window is spawned. However, when run from a terminal window, Console.WriteLine
calls don't appear at all13 replies