Created
December 24, 2019 16:11
-
-
Save sojournercntl/0289533966635ee60df8633723ab56f6 to your computer and use it in GitHub Desktop.
The for OS detection in .net core
This file contains 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
public static class OS | |
{ | |
public static bool IsWin() => | |
RuntimeInformation.IsOSPlatform(OSPlatform.Windows); | |
public static bool IsMac() => | |
RuntimeInformation.IsOSPlatform(OSPlatform.OSX); | |
public static bool IsGnu() => | |
RuntimeInformation.IsOSPlatform(OSPlatform.Linux); | |
public static string GetCurrent() | |
{ | |
return | |
(IsWin() ? "win" : null) ?? | |
(IsMac() ? "mac" : null) ?? | |
(IsGnu() ? "gnu" : null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment