http://www.mono-project.com/docs/faq/technical/#how-to-detect-the-execution-platform
http://stackoverflow.com/questions/692410/hello-os-with-c-sharp-mono
http://stackoverflow.com/questions/10138040/how-to-detect-properly-windows-linux-mac-operating-systems
http://stackoverflow.com/questions/32415679/how-can-i-get-the-real-os-version-in-c
if (Type.GetType("Mono.Runtime") != null)
{
// we're on Mono
IsMono = true;
}
else
IsMono = false;
int p = (int) Environment.OSVersion.Platform;
if ((p == 4) || (p == 6) || (p == 128)) {
Console.WriteLine ("Running on Unix");
} else {
Console.WriteLine ("NOT running on Unix");
}
public static bool IsLinux
{
get {
bool isLinux = System.IO.Path.DirectorySeparatorChar == '/';
return isLinux;
}
}
__MonoCS__
http://stackoverflow.com/questions/329043/how-can-i-conditionally-compile-my-c-sharp-for-mono-vs-microsoft-net/329072#329072
Platform property in msbuild
https://msdn.microsoft.com/en-us/library/bb629394.aspx
- Platform
- The operating system you are building for. Valid values are "Any CPU", "x86", and "x64".
manifesting
manifesting your application for Windows 10 so that Environment.OSVersion.Version
would return the right value (I recently had to do this to get the software I work on to detect Windows 10),
but I'm not sure it would help you if you are on a non-Windows platform.
I did a bit of searching and it seems that Mono, for instance, seems to have problems listening to the app.manifest file.