C#7.1无法发布 [英] C# 7.1 can't be published

查看:244
本文介绍了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:...\.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),但没有任何区别.

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?

推荐答案

在您的.pubxml文件中添加<LangVersion>latest</LangVersion>使得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无法发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆