How to detect properly Windows, Linux & Mac operating systems
Per the remarks on the Environment.OSVersion Property page:
The Environment.OSVersion property does not provide a reliable way to identify the exact operating system and its version. Therefore, we do not recommend that you use this method. Instead: To identify the operating system platform, use the RuntimeInformation.IsOSPlatform method.
RuntimeInformation.IsOSPlatform worked for what I needed.
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
// Your OSX code here.
}
elseif (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// Your Linux code here.
}
Maybe check out the IsRunningOnMac method in the Pinta source: