简体   繁体   English

使用msbuild构建时出现C#版本错误,使用Visual Studio可以

[英]C# version error when building with msbuild, ok with Visual Studio

I can build my project just fine using Visual Studio 2017; 我可以使用Visual Studio 2017很好地构建项目; however when I use msbuild 15, I get this eror: 但是,当我使用msbuild 15时,出现以下错误:

error CS8306: Tuple element name 'value' is inferred. 错误CS8306:推断出元组元素名称“值”。 Please use language version 7.1 or greater to access an element by its inferred name. 请使用语言版本7.1或更高版本通过推断的名称访问元素。

The language version is set to 7.3 in my project file; 在我的项目文件中,语言版本设置为7.3。 why would I get this error when running msbuild? 为什么在运行msbuild时会出现此错误?

I figured it out - thanks to Olivier Jacot-Descombes who suggested I look in the project properties! 我想通了-感谢Olivier Jacot-Descombes建议我查看项目属性!

What I needed to do was set my C# version for all platforms (eg any CPU, x68, x64) to 7.3 in addition to setting it for all configurations (debug/release) as he'd suggested. 除了他建议的所有配置 (调试/发行版)设置之外,我需要做的是将所有平台 (例如,任何CPU,x68,x64)的C#版本设置为7.3。

MSbuild 15 does not support .NET Framework 4.7.2 . MSbuild 15不支持.NET Framework 4.7.2

Per the GitHub issue, this was merged in May: github.com/Microsoft/msbuild/issues/3285 根据GitHub问题,该文档已于5月合并: github.com/Microsoft/msbuild/issues/3285

Version 15.7.180 should work: https://github.com/Microsoft/msbuild/releases/tag/v15.7.180.61344 版本15.7.180应该可以正常工作: https : //github.com/Microsoft/msbuild/releases/tag/v15.7.180.61344

Edit: Version 15.8.166.59604 shipped with Visual Studio 15.8, which was released in April. 编辑:Visual Studio 15.8附带的版本15.8.166.59604 ,于4月发布。 Though, support for .NET Framework 4.7.2, was implemented in May. 但是,对.NET Framework 4.7.2的支持已在5月实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用MSBuild时,Visual Studio Android解决方案在遇到C#版本冲突时停止构建 - Visual Studio Android solution stops building upon hitting C# version conflict when using MSBuild 在 Visual Studio 中构建 C# 应用程序时,如何在可执行文件名中嵌入版本信息? - How to embed the version information in the executable file name when building C# application in Visual Studio? 使用 c#、visual studio 和 msbuild 编辑解决方案 - editing a solution with c#, visual studio and msbuild 需要在命令行上使用较低版本的msbuild C#项目,而无需Visual Studio - Need to msbuild C# project of lower version on commandline, without Visual Studio C# 使用 Visual Studio 构建 Win 7 和 8 应用程序 - C# Building Win 7 & 8 Apps with Visual Studio 使用C#代码中的msbuild构建Visual Studio解决方案 - Build visual studio solution using msbuild from c# code 将我自己的C#项目配置添加到MSBuild / Visual Studio中 - Adding my own configuration for a C# project into MSBuild / Visual Studio C#Visual Studio项目属性和MSBuild宏 - C# Visual Studio Project Properties & MSBuild Macros 使用 XUnit 构建测试项目时捕获 c# MSBuild 输出 - Capture c# MSBuild output when building a test project with XUnit 构建时 Visual Studio 中出现奇怪的功能区错误 - Strange Ribbon error in Visual Studio when building
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM