在MSBuild中使用C#7.1 [英] Using C# 7.1 with MSBuild

查看:108
本文介绍了在MSBuild中使用C#7.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使用新的 C#7.1语言功能在Visual Studio 2017中,您可以将设置<LangVersion>latest</LangVersion>添加到项目文件中.

To use the new C# 7.1 language features with Visual Studio 2017, you add the setting <LangVersion>latest</LangVersion> to your project file(s).

但是,从MSBuild(位于C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin的版本15.3.409.57025)构建此类项目会导致错误:

However, building such projects from MSBuild (version 15.3.409.57025, located at C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin) results in an error:

CSC : error CS1617: Invalid option 'latest' for /langversion;
must be ISO-1, ISO-2, Default or an integer in range 1 to 6.

MSBuild尚不支持此功能,还是可以使它正常工作?

Is this feature just not yet supported by MSBuild, or is it possible to get this working?

这涵盖了200多个最初在Visual Studio 2013和2015中创建的项目.使用

This covers 200+ projects that were originally created variously in Visual Studio 2013 and 2015. They were all re-targeted to .NET 4.7 using the Target Framework Migrator tool (which saved lots of clicking and appears - based on inspecting .csproj file changes - to do the job correctly).

所有项目均已从Visual Studio 2017成功构建.

The projects all build successfully from Visual Studio 2017.

推荐答案

我们发现我们的MVC项目正在触发此问题.

We discovered that our MVC projects were triggering this issue.

要修复,我们将这些项目使用的Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet软件包从版本 1.0.0 更新到了 1.0.7 .

To fix, we updated the Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package used by these projects from version 1.0.0 to 1.0.7.

这篇关于在MSBuild中使用C#7.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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