What you are asking for is possible but needs a bit of work.
-
Define a preprocessor variable in your
csproj
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' "> <DefineConstants>_WINDOWS</DefineConstants> </PropertyGroup>
-
Use that in your code
#if _WINDOWS // your windows stuff #else // your *nix stuff #endif
I find this technique useful when you have constants that are dependent on the OS (for example native library names)