title: How to specify the equivalent of /features:strict (of csc.exe) to msbuild.exe or in the .csproj file?
body: <h1>Introduction</h1>
  <p>Consider this simple (and bad) C# class:</p>
  <pre><code>using System;
  
  namespace N
  {
    static class C
    {
      static void M(DateTime d)
      {
        if (d == null)
          Console.WriteLine(&quot;Yes&quot;);
        else
          Console.WriteLine(&quot;No&quot;);
      }
  
      static void L(object o)
      {
        if (o is Nullable)
          Console.WriteLine(&quot;Yes&quot;);
        else
          Console.WriteLine(&quot;No&quot;);
      }
  
    }
  }
  </code></pre>
  <p>Both methods <code>M</code> and <code>L</code> have serious issues.</p>
  <p>In <code>M</code>, we ask if a value of the non-nullable struct <code>DateTime</code> is equal to null via the lifted <code>==</code> operator (which exists since <code>DateTime</code> overloads <code>operator ==</code>). This is always falls, and the compiler can tell at compile-time, so we have a branch (<code>&quot;Yes&quot;</code>) which is unreachable.</p>
  <p>In <code>N</code> we ask if <code>o</code> is an instance of the <code>static class Nullable</code> which can never be the case (note, the static class <code>Nullable</code> is not the same as the struct <code>Nullable&lt;&gt;</code>). Again, this is a developer mistake, and the <code>&quot;Yes&quot;</code> statement is unreachable.</p>
  <p>We do want a compile-time warning (or &quot;warning as error&quot;) in these cases, right?</p>
  <p>As it seems, through gradual accumulation of compiler errors and/or omissions in the old C# compiler that was used for C# 1.0 through 5.0, the expected compile-time warnings failed to appear with the old compiler. Luckily we have Roslyn/C# 6.0/Visual Studio 2015 now, and expect to get a warning. But no, because of the desire to not emit warnings from Roslyn that where not present with the old compiler (backwards compatibility?), these situations are still not warned against.</p>
  <p>However, if you compile from the command line, with <code>csc.exe</code>, you can use:</p>
  <pre><code>csc.exe /features:strict ... ...
  </code></pre>
  <p>and you will get the warnings you want! <code>/features:strict</code> makes <code>csc.exe</code> include warnings that the old C# compiler &quot;fogot&quot;.</p>
  <h1>My question</h1>
  <p><em>How do I specify the equivalent of <code>/features:strict</code> to <code>msbuild.exe</code> command line <strong>or</strong> in the <code>.csproj</code> file?</em></p>
  <p>Sometimes, e.g. when we have XAML in our build project, it is not easy to use <code>csc.exe</code> directly, we have to use a <code>.csproj</code> file and compile through <code>msbuild.exe</code>.</p>