{"action":"closed","issue":{"url":"https://api.github.com/repos/dotnet/core/issues/2060","repository_url":"https://api.github.com/repos/dotnet/core","labels_url":"https://api.github.com/repos/dotnet/core/issues/2060/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/core/issues/2060/comments","events_url":"https://api.github.com/repos/dotnet/core/issues/2060/events","html_url":"https://github.com/dotnet/core/issues/2060","id":380839537,"node_id":"MDU6SXNzdWUzODA4Mzk1Mzc=","number":2060,"title":"Cannot run .net core console app on linux with supervisor","user":{"login":"serdam55","id":30700983,"node_id":"MDQ6VXNlcjMwNzAwOTgz","avatar_url":"https://avatars3.githubusercontent.com/u/30700983?v=4","gravatar_id":"","url":"https://api.github.com/users/serdam55","html_url":"https://github.com/serdam55","followers_url":"https://api.github.com/users/serdam55/followers","following_url":"https://api.github.com/users/serdam55/following{/other_user}","gists_url":"https://api.github.com/users/serdam55/gists{/gist_id}","starred_url":"https://api.github.com/users/serdam55/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serdam55/subscriptions","organizations_url":"https://api.github.com/users/serdam55/orgs","repos_url":"https://api.github.com/users/serdam55/repos","events_url":"https://api.github.com/users/serdam55/events{/privacy}","received_events_url":"https://api.github.com/users/serdam55/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-11-14T18:55:48Z","updated_at":"2018-11-16T19:59:16Z","closed_at":"2018-11-16T19:59:16Z","author_association":"NONE","body":"I have created a console application which have a menu that allow me to navigate between the menu items. I handle the navigation logic in this method:\r\n\r\n```c#\r\npublic virtual void UpdateMenu()\r\n{\r\n    switch (Console.ReadKey(true).Key)\r\n    {\r\n        case ConsoleKey.UpArrow:\r\n            {\r\n                if (cursor > 0)\r\n                {\r\n                    cursor--;\r\n                    Console.Clear();\r\n                    drawWithHeader();\r\n                }\r\n            }\r\n            break;\r\n        case ConsoleKey.DownArrow:\r\n            {\r\n                if (cursor < (menuItemList.Count - 1))\r\n                {\r\n                    cursor++;\r\n                    Console.Clear();\r\n                    drawWithHeader();\r\n                }\r\n            }\r\n            break;\r\n        case ConsoleKey.Escape:\r\n            {\r\n                if (ParentMenu != null)\r\n                {\r\n\r\n                    hideMenu();\r\n                }\r\n            }\r\n            break;\r\n        case ConsoleKey.Enter:\r\n            {\r\n                Console.Clear();\r\n                drawHeader();\r\n                Console.CursorVisible = true;\r\n                menuItemList[cursor].Action();\r\n                Console.CursorVisible = false;\r\n                Console.Clear();\r\n                drawWithHeader();\r\n            }\r\n            break;\r\n        default:\r\n            {\r\n                // Unsuported key. Do nothing....\r\n            }\r\n            break;\r\n    }\r\n}\r\n```\r\n\r\n[here](https://pastebin.com/SpkmCBnq) the full class.\r\n\r\nNow on windows all works well, but when I run this application on my linux server with supervisor I get:\r\n\r\n> Unhandled Exception: System.InvalidOperationException: Cannot read key when either application does not have a console or when console input has been redirected. Try Console.Read.\r\n\r\nThe stacktrace display:\r\n\r\n```\r\n at System.ConsolePal.ReadKey(Boolean intercept)\r\n at System.Console.ReadKey();\r\n at AppRazen.Menu.ConsoleMenu.UpdateMenu();  \r\n```\r\n\r\nAfter some searching I discovered that this problem is related to the ReadKey() method which is not fully [compatible with linux](https://stackoverflow.com/questions/46655517/why-is-net-core-handling-readkey-differently-on-raspbian). And the solution proposed [here](https://stackoverflow.com/questions/46901071/readkey-not-working-in-net-core) simply doesn't work in my case, because the user has used OminSharp.\r\n\r\nI also tried to set `ReadKey(false)` but this didn't fixed the problem, and I also tried to handle all the stuff inside `UpdateMenu` with `Console.Read()` but the console seems stuck.\r\n\r\nNote that this issue happen **only** when I run my script in linux supervisor not with the default command like `dotnet AppRazen.dll`\r\n\r\nEssentially I'm running the script with a daemon service like this:\r\n\r\n```\r\n[Unit]\r\nDescription = Daemon description\r\n\r\n[Service]\r\nExecStart = /usr/bin/dotnet /home/root/Desktop/publish/AppRazen.dll\r\nWorkingDirectory= /home/root/Desktop/publish\r\nRestart = always\r\nRestartSec = 3\r\n\r\n[Install]\r\nWantedBy = multi-user.target\r\n```\r\n\r\nI honestly I don't know how can I fix that. Someone have any ideas?\r\n\r\nThanks in advance."}}
{"actor":{"display_login":"karelz"}}