You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Invalid option 'option' for **LangVersion**. Use `<LangVersion>?</LangVersion>` to list supported values.
13
+
Invalid option 'option' for **LangVersion**. Use `?` to list supported values.
14
14
15
15
This error occurs if you used the [**LangVersion**](../language-reference/compiler-options/language.md#langversion) command line switch or project setting but didn't specify a valid language option. To resolve this error, check the command line syntax or project setting and change it to one of the listed options.
16
16
17
17
For example, compiling with `csc -langversion:ISO` will generate error CS1617.
18
18
19
+
## How to list supported language versions
20
+
21
+
To see a list of supported language versions, you reference the table in this article, compile with `-langversion:?`, or temporarily set `<LangVersion>?</LangVersion>` in your project file before building.
22
+
23
+
### Use the reference table (recommended)
24
+
25
+
The most reliable way to see supported language versions is to consult the reference table at the end of this article, which lists all currently supported language versions.
26
+
27
+
### Use the C# compiler directly
28
+
29
+
Use the `-langversion:?` option with the C# compiler. You need to find the path to `csc.dll` in your .NET SDK installation:
The exact path varies based on your operating system and .NET SDK version.
42
+
43
+
### Use a project file with diagnostic output (not recommended)
44
+
45
+
You can temporarily set `<LangVersion>?</LangVersion>` in your project file and build with diagnostic verbosity:
46
+
47
+
```console
48
+
dotnet build -v diagnostic
49
+
```
50
+
51
+
Look for the "Supported language versions:" line in the output.
52
+
53
+
> [!WARNING]
54
+
> Setting `<LangVersion>?</LangVersion>` in a project file will cause the build to fail after displaying the supported versions. This is because the compiler exits after listing the versions instead of continuing to compile your code. Remove this setting after viewing the list.
55
+
19
56
## Valid values for -langversion
20
57
21
58
The valid values for the language versions depend on the .NET version you are using. See [the language version rules](../language-reference/language-versioning.md#defaults) for more information on which language version is available with which version of .NET. If you are receiving this error while attempting to use a newer language version, either downgrade to a lower language version or update your .NET SDK to a version that supports the language version.
0 commit comments