Basic example that shows how to use #if Linux Windows OSX to perform conditional compilation in C# .NET Core. For some reason, it was very hard to find working examples. And you don't need to involve MEF for this basic example.
It was built in Visual Studio 2019, but should work with earlier versions.
This example was taken from this blog post: https://blog.magnusmontin.net/2018/11/05/platform-conditional-compilation-in-net-core/