C # 7.1 cannot be published

I have an ASP.NET Core C # web application. I made some changes that now use C # 7.1 features. I changed the version of the project, so it compiles and works fine. However, when I try to publish a project, I get an error message:

The default literal function is not available in C # 7.0. Use language version 7.1 or higher.

Compile the command that I see:

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 that didn't make any difference.

Is there a Visual Studio setting that affects publishing specifically?

The UPDATE . The console application does not seem to have this problem. If it is successfully built, it is also successfully published. However, the web application does not publish. Has anyone successfully published an ASP.NET Core web application with C # 7.1 features?

+4
source share
3 answers

Adding <LangVersion>latest</LangVersion>to your .pubxml file enabled Visual Studio 2017 (15.5.2 in my case) to publish.

Source: https://developercommunity.visualstudio.com/solutions/166543/view.html

+7
source

Update:
After updating my VS2017 from version 15.4.5 to 15.5.2, I can reproduce the problem and I get an error message

" " # 7.0. , 7.1

@Jeremy Cook :
<LangVersion>latest</LangVersion> .pubxml


LangVersion . csproj xml , visual studio.

,
, , # 7.1, , Debug, Release

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <LangVersion>7.1</LangVersion>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <LangVersion>7.1</LangVersion>
  </PropertyGroup>

</Project>

enter image description here

+6

, Nuget. , Nuget # 7.1. , , Nuget.exe , # 7.1

-2

Source: https://habr.com/ru/post/1691249/


All Articles