Answer the question
In order to leave comments, you need to log in
How to quickly detect OS (Windows/Linux) in C# .Net 5/6 cross-platform development?
It seems that the task is banal, but somehow I quickly did not find a solution.
Are there any built-in .Net tools to determine under which OS the program is running?
Something other than how to define OperatingSystem.Platform or some separate definition code of your own, but something aimed specifically at cross-platform.
And even better, if there are some (PS ready-made "out of the box") preprocessor directives, so that the OS definition does not appear in the code?
Those. something like:
#if LINUX
string cmd = @"/bin/bash";
#else
string cmd = @"c:\Windows\System32\cmd.exe"
#end
Answer the question
In order to leave comments, you need to log in
And even better, if there are some preprocessor directives, so that the OS definition does not appear in the code?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question