I'm using the VS2019 IDE. I have a solution with various class library projects and a website. The website is not in a csproj file; it's a locally hosted IIS website and VS2019 lists it as http://localhost/websitename/ in Solution Explorer. Everything is targeting .NET Framework 4.7.2. The website has the Microsoft.CodeDom.Providers.DotNetCompilerPlatform.3.6.0 NuGet package installed.
When using a newer language feature like the abbreviated new operator in this example:
StringBuilder sb = new();
...the class libraries compile just fine. Within the website, the background compiler doesn't complain about this, either. But if I build the website, I get:
CS8124: Tuple must contain at least two elements.
CS1526: A new expression requires (), [], or {} after type
If I change the code back to the classic way:
StringBuilder sb = new StringBuilder();
...the website builds fine, but the background compiler gives the following "message":
IDE0090 'new' expression can be simplified
The csproj files for the class libraries all contain:
<LangVersion>latest</LangVersion>
...and the web.config contains:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:latest /nowarn:1659;1699;1701" />
What am I missing?
PS: I don't necessarily need the latest language features. I'd be fine if the code just compiled the same way between the background compiler and the one that's used when VS does builds.
