gpt4 book ai didi

C# 7.1 无法发布

转载 作者:IT王子 更新时间:2023-10-29 04:12:17 24 4
gpt4 key购买 nike

我有 ASP.NET Core C# 网络应用程序。我做了一些更改,现在使用 C# 7.1 功能。我更改了项目版本,因此它可以正常编译和运行。但是,当我尝试发布该项目时,出现错误:

Feature 'default literal' is not available in C# 7.0. Please use language version 7.1 or greater.

我看到的编译命令是:

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`

按照其他地方的建议,我安装了 Microsoft.Net.Compilers (v2.6.1),但没有任何区别。

是否有专门影响发布的 Visual Studio 设置?

更新:看起来控制台应用程序没有这个问题。如果它构建成功,它也会成功发布。但是,Web 应用程序不会发布。有人成功发布了具有 C# 7.1 功能的 ASP.NET Core Web 应用程序吗?

最佳答案

添加<LangVersion>latest</LangVersion>添加到您的 .pubxml 文件使 Visual Studio 2017(在我的例子中是 15.5.2)发布成为可能。

来源:https://developercommunity.visualstudio.com/solutions/166543/view.html

关于C# 7.1 无法发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47946732/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com