.NET 6 Preview 7 breaks builds that set $(LangVersion) 8.0
See original GitHub issueUsing 6.0.100-preview.7.21369.5
, you can do:
dotnet new console
dotnet build -p:LangVersion=8.0 -bl
This fails with:
C:\src\globalusing\Program.cs(2,1): error CS8400: Feature 'top-level statements' is not available in C# 8.0. Please use language version 9.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(2,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(3,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(4,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(5,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(6,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(7,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(8,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
Binlog: msbuild.zip
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11 (9 by maintainers)
Top Results From Across the Web
Announcing .NET 8 Preview 7
NET 8 Preview 7 is now available. We're already at the final preview release for .NET 8 and will now shift to release...
Read more >C# language versioning - C# Guide
The value preview uses the latest available preview C# language version that your compiler supports. Configure multiple projects. To configure ...
Read more >How to change C# Language Version for all of the projects ...
To set a version for all your project at once, you can create a file named Directory.Build.props (case-sensitive on Linux) at the root...
Read more >VS 2019 for Mac Preview 2: Error CS1617: Invalid option ' ...
NET Core 3.0 ASP.NET project I'm getting the following build error. Error CS1617: Invalid option '8.0' for /langversion. Use '/langversion:?' to list supported ......
Read more >What's New in .NET 7? Discover ALL .NET 7 Features
Explore the exciting new features of .NET 7, designed to deliver faster and more efficient performance with greater reliability.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My thoughts here are that the customer has willingly downgraded one aspect of the project here (the language version). It is reasonable that they may need to downgrade other parts of the project here to compensate (implicit global usings)
Our general focus is that we default all of our experiences, including language version, based on the selected target framework. It’s a very simple model for us to all follow. Particularly because all of our experiences have on “off” switch. That means the default experience is as vibrant as we want and customers have the knobs to disable experiences they don’t want or aren’t compatible with other knobs.
I think we can close this in favor of https://github.com/dotnet/sdk/issues/19521, this feature is being redesigned.
The idea is you will have to opt into it with
ImplicitUsings=true
, so we wouldn’t have hit an issue if that was the case.