I want to build a .net core library that will have platform specific code for doing win32 and osx calls and when compiling the library for each target os, I want to include the correct os code.
I've looked at the corefx and lots of documents and after much googling the only way I've found is to perform OS detection at runtime but that is both inefficient and tedious. In the case of corefx, they have a complex build system that seems to automagically pull in platform specific files but that relies on msbuild and more. Am I missing something?
How do I conditionally target code for a OS either at the file level or code level such as:
#if osx
// come code
#endif
Or, as per golangs way, by putting the os name in the filename such as MyClass.osx.cs for osx code and MyClass.cs for non platform stuff and the build process will take of including the correct files itself.
I'm using Visual Studio code and project.json.
(I guess in Visual studio I could define each platform target and include my own defines but I'm on osx)
Thanks in advance.