C# 7.1 can#39;t be published(C# 7.1 无法发布)
问题描述
我有 ASP.NET Core C# Web 应用程序.我做了一些更改,现在使用 C# 7.1 功能.我更改了项目版本,所以它编译并运行良好.但是,当我尝试发布该项目时,我收到一个错误:
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:
功能默认文字"在 C# 7.0 中不可用.请使用 7.1 或更高版本的语言.
Feature 'default literal' is not available in C# 7.0. Please use language version 7.1 or greater.
我看到的编译命令是:
C:....nugetpackagesmicrosoft.net.compilers2.6.1 oolscsc.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),但没有任何区别.
As suggested elsewhere, I installed Microsoft.Net.Compilers
(v2.6.1), but it didn't make any difference.
是否有专门影响发布的 Visual Studio 设置?
Is there a Visual Studio setting that affects publish specifically?
更新:看起来控制台应用程序没有这个问题.如果它构建成功,它也会成功发布.但是,Web 应用程序不会发布.是否有人成功发布了具有 C# 7.1 功能的 ASP.NET Core Web 应用程序?
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?
推荐答案
将 <LangVersion>latest</LangVersion>
添加到您的 .pubxml 文件中,使 Visual Studio 2017 (15.5.2就我而言)发布.
Adding <LangVersion>latest</LangVersion>
to your .pubxml file made it possible for Visual Studio 2017 (15.5.2 in my case) to publish.
来源:https://developercommunity.visualstudio.com/solutions/166543/view.html
这篇关于C# 7.1 无法发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C# 7.1 无法发布


- 在 C# 中异步处理项目队列 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- 使用 rss + c# 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01