title: Visual Studio 2019 project upgrade to C#8 build failed
body: <p>For one of our projects we're trying to upgrade to use C#8 instead of C#7.1. The upgrade looks like it works, because the compiler looks like it takes C#8 statements (it doesn't mark it as an error). However, when I build the project I get a build failed without any errors showing initially.</p>
  
  <p>The code to test C#8 is of the following lines:</p>
  
  <pre><code>private string TestCSharp8(int x)
  {
      return x switch
      {
          0 =&gt; "ZERO",
          1 =&gt; "ONE",
          2 =&gt; "TWO",
          3 =&gt; "THREE",
          _ =&gt; "OTHER"
      };
  }
  </code></pre>
  
  <p>The IDE is accepting this code and even suggests to reformat it to this when writing an 'old-fashioned' <code>switch</code> statement. However, when I then build the solution I get the following output in the Error List:
  <a href="https://i.stack.imgur.com/4VBTb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4VBTb.png" alt="enter image description here"></a></p>
  
  <p>But then the Ouput log shows the following:</p>
  
  <p><a href="https://i.stack.imgur.com/C74Y2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C74Y2.png" alt="enter image description here"></a></p>
  
  <p>When I look at the build log after I put the Ouput verbosity to detailed, I can see the following errors occur:</p>
  
  <pre><code>1&gt;C:\VisualStudio\Repos\XXX\YYY\ZZZ\Repositories\ABC.cs(301,5,301,6): error CS1597: Semicolon after method or accessor block is not valid
  1&gt;C:\VisualStudio\Repos\XXX\YYY\ZZZ\Repositories\ABC.cs(304,1,304,2): error CS1022: Type or namespace definition, or end-of-file expected
  1&gt;Done executing task "Csc" -- FAILED.
  1&gt;Done building target "CoreCompile" in project "XYZ.csproj" -- FAILED.
  </code></pre>
  
  <p>In the project file I have set the <code>&lt;LangVersion&gt;</code> to <code>latest</code>. The target framework we're targetting is .NET Framework 4.7.1.</p>
  
  <p>The strange thing is all of this works <strong>and</strong> builds in another solution we're having.</p>
  
  <p>So, can someone please help me in the right direction on how to fix this? At the moment I don't know where to look for the solution.</p>