Как получить информацию о среде выполнения .Net Core

У меня есть приложение, которое работает на Linux и Windows. Мне нужно знать, где работает приложение, чтобы использовать разностный код. Спасибо


person Serhii Shemshur    schedule 29.08.2016    source источник
comment
попробуйте использовать RuntimeInformation из System.Runtime.InteropServices: RuntimeInformation.IsOSPlatform(OSPlatform.Linux) или RuntimeInformation.IsOSPlatform(OSPlatform.Windows) или RuntimeInformation.IsOSPlatform(OSPlatform.OSX)   -  person Oleg    schedule 29.08.2016
comment
См. мой подробный ответ в другой ветке   -  person jariq    schedule 29.08.2016


Ответы (1)


Вероятно, вы ищете System.Runtime.InteropServices.RuntimeInformation с функцией IsOsPlatform для выполнения проверок во время выполнения.

Посмотрите видеоруководство https://channel9.msdn.com/Series/aspnetmonsters/ASPNET-Monsters-Episode-46-Finding-Platform-Information монстров ASP.NET.

person Ralf Bönning    schedule 29.08.2016