I want to create a .net base library that will have platform-specific code for making win32 and osx calls, and when compiling the library for each target os, I want to include the correct os code.
I looked at corefx and a large number of documents, and after a lot of google searches, the only way I found was to run an OS definition at runtime, but this is inefficient and tedious. In the case of corefx, they have a complex build system, which seems to automatically transfer files defined by the platform, but which depend on msbuild, etc. Did I miss something?
How to conditionally configure code for the OS both at the file level and at the code level, for example:
#if osx
#endif
Or, according to the golangs method, by placing the os name in the file name, such as MyClass.osx.cs for the osx code and MyClass.cs for the non-platform, and the build process will include the correct files.
I am using Visual Studio code and project.json.
(I think in Visual Studio I could define each target platform and include my own definitions, but I'm on osx)
Thanks in advance.
source
share