title: Conditional compilation symbol for a .NET Core class library
body: <p>I have created a .NET Core R2 class library and have some common code that I use for several different platforms.</p>
  
  <p>Some of the code is not valid in the .NET Core platform and so I wish to wrap it around a <em>conditional compilation symbol</em>. I first searched the Internet to see if I could find a built-in symbol (like SILVERLIGHT for <a href="http://en.wikipedia.org/wiki/Microsoft_Silverlight" rel="noreferrer">Silverlight</a> applications and WINFX_CORE for Windows&nbsp;8 applications), but I was not able to find any information, so I decided to create my own symbol. This also does not seem to work.</p>
  
  <p>From everything I read, adding and using a symbol should be easy. Just add a value to the conditional compilation symbols in the project properties &rarr; <em>Build</em> tab. I did that, but it does not seem to work.  Here are a couple of screenshots...</p>
  
  <p><a href="https://i.stack.imgur.com/rgAOI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rgAOI.png" alt="Enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/UdfXb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UdfXb.png" alt="Enter image description here"></a></p>
  
  <p>Notice that I added a <code>NET_CORE</code> value in the conditional compilation symbol, but when I use it in code the code is not being ignored.</p>
  
  <ol>
  <li><p>Is there is a built-in symbol for the .NET Core platform (I am using R2)?</p></li>
  <li><p>If there is not one, what am I doing wrong creating my own symbol?</p></li>
  </ol>
  
  <p>The .xproj file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''"&gt;14.0&lt;/VisualStudioVersion&gt;
      &lt;VSToolsPath Condition="'$(VSToolsPath)' == ''"&gt;$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)&lt;/VSToolsPath&gt;
    &lt;/PropertyGroup&gt;
    &lt;Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /&gt;
    &lt;PropertyGroup Label="Globals"&gt;
      &lt;ProjectGuid&gt;253184d7-9b42-4233-a871-8cfa3ee9e83e&lt;/ProjectGuid&gt;
      &lt;RootNamespace&gt;Linq2Db.NetCore&lt;/RootNamespace&gt;
      &lt;BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' "&gt;.\obj&lt;/BaseIntermediateOutputPath&gt;
      &lt;OutputPath Condition="'$(OutputPath)'=='' "&gt;.\bin\&lt;/OutputPath&gt;
      &lt;TargetFrameworkVersion&gt;v4.6.1&lt;/TargetFrameworkVersion&gt;
      &lt;SccProjectName&gt;SAK&lt;/SccProjectName&gt;
      &lt;SccProvider&gt;SAK&lt;/SccProvider&gt;
      &lt;SccAuxPath&gt;SAK&lt;/SccAuxPath&gt;
      &lt;SccLocalPath&gt;SAK&lt;/SccLocalPath&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup&gt;
      &lt;SchemaVersion&gt;2.0&lt;/SchemaVersion&gt;
    &lt;/PropertyGroup&gt;
    &lt;Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <hr/>
  
  <p><strong>UPDATE:</strong>  I was able to resolve this using the link in the provided answer. Here are the details...</p>
  
  <p>Originally the <code>project.json</code> file looked like this...</p>
  
  <pre><code>{
    "dependencies": {
          "NETStandard.Library": "1.5.0-rc2-24027"
    },
    "frameworks": {
      "netstandard1.5": {
        "imports": "dnxcore50"
      }
    },
    "buildOptions": {
      "defines": [ "NET_CORE" ]
    }
  }
  </code></pre>
  
  <p>I resolved the issue by changing it to this...</p>
  
  <pre><code>{
    "frameworks": {
      "netstandard1.5": {
        "imports": "dnxcore50",
        "dependencies": {
          "NETStandard.Library": "1.5.0-rc2-24027"
        },
        "buildOptions": {
          "define": [ "NET_CORE" ]
        }
      }
    }
  }
  </code></pre>