title: dot net core build platform/os specific code or class files
body: <p>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.</p>
  
  <p>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?</p>
  
  <p>How do I conditionally target code for a OS either at the file level or code level such as:</p>
  
  <pre><code>#if osx
  // come code
  #endif
  </code></pre>
  
  <p>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. </p>
  
  <p>I'm using Visual Studio code and project.json.</p>
  
  <p>(I guess in Visual studio I could define each platform target and include my own defines but I'm on osx)</p>
  
  <p>Thanks in advance.</p>