【问题标题】:How to get the command line C# compiler to work for C# version > 5? [duplicate]如何让命令行 C# 编译器适用于 C# 版本 > 5? [复制]
【发布时间】:2018-10-04 22:08:23
【问题描述】:

我使用命令行手动调用 C# 编译器来编译 C# 源文件。但是,编译坚持使用 C# 5。我使用 VS2017 的路径访问它,所以我希望它也能在更高版本的 C# 上工作。设置/langversion 属性似乎不起作用。

有什么帮助吗?

PS C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Roslyn> csc
Microsoft (R) Visual C# Compiler version 4.7.2558.0 for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

warning CS2008: No source files specified error CS1562: Outputs without source must have the /out option specified

.. 但仅支持 C# 5 以下的语言版本

【问题讨论】:

  • 嗯,你似乎做对了,那个目录有最新版本的 csc.exe。告诉我们该文件的文件大小和时间戳,以及您是否使用了开发人员命令提示符。 “PS”不太令人鼓舞。

标签: c# roslyn


【解决方案1】:

您的 Visual Studio 安装或构建工具安装已过期。

使用当前版本,即 15.8.6,您应该得到以下输出:

PS C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn> .\csc
Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354)
Copyright (C) Microsoft Corporation. All rights reserved.

warning CS2008: No source files specified.
error CS1562: Outputs without source must have the /out option specified

【讨论】:

    猜你喜欢
    • 2018-05-17
    • 2022-01-19
    • 2011-08-27
    • 2010-11-17
    • 2016-01-10
    • 1970-01-01
    • 2013-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多