I have ASP.NET Core C# web application. I made some changes that now use C# 7.1 features. I changed project version, so it compiles and runs fine. However, when I try to publish the project, I am getting an error:
Feature 'default literal' is not available in C# 7.0. Please use language version 7.1 or greater.
Compile command that I see is:
C:...\.nuget\packages\microsoft.net.compilers\2.6.1\tools\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1705,1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;RELEASE;NETCOREAPP2_0 /errorendlocation /preferreduilang:en-US /warnaserror+:NU1605`
As suggested elsewhere, I installed Microsoft.Net.Compilers
(v2.6.1), but it didn't make any difference.
Is there a Visual Studio setting that affects publish specifically?
UPDATE: Looks like a console application doesn't have this problem. If it builds successfully, it publishes successfully as well. However, the web application does not publish. Was anybody successful in publishing ASP.NET Core web application with C# 7.1 features?
Project -> Project Properties (bottom) -> Build -> Advanced -> Language Version
. Change tominor version (latest)
orC# 7.1
– Kinsleyint x = HttpContext.Items?.Count ?? default;
and changed language to 7.1 (also tried 7.2, or latest - no difference). It compiles, but doesn't publish. I uploaded to github.com/virshu/SOExample But good news - it does publish with dotnet CLI. The only difference I see is that I have VS Community and you have Enterprise; so maybe the difference is indeed in the version of VS – Rivacsc.exe
then mine. I've uploaded my Visual Studio configuration details, as well as publish logs to Gist - maybe that can help you gist.github.com/oleh-zheleznyak/… – Jollantadotnet cli
is acceptable workaround, and in line with scripting deployment, anyway! – Riva