❔ ✅ C# 12 Features Work Locally, but Not in Docker with .NET 6.0
My project's target framework is net6.0. It all works fine locally. In docker, the base image I'm using for building is
mcr.microsoft.com/dotnet/sdk:6.0
. For some reason when I build the docker image, it fails on the lines that use the new C# features. What have I misunderstood? I specify LangVersion 12.0 in my .csproj file.6 Replies
.NET 6 is C# 10, .NET 7 is C# 11, .NET 8 (currently only in preview) is C# 12
You probably shouldn't expect C# 12 to work on .NET 6
Thanks! So how come it works locally from my machine when I run from visual studio? I have sdks versions 6 and 7 installed. Does Vs ignore the target framework in the csproj?
Might be that you're not using features which require runtime support, in which case I don't know why there would be a difference between local and Docker
The target framework only controls the runtime
The SDK is controlled by global.json
Without one, the latest installed SDK is used
@james441 since the Docker build env is using the .net 6 sdk, the latest c# you can use is 10
Ah bingo, that explains why there's a difference. Thank you very much!
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.