Skip to content

C# 12 need net8 sdk to be installed in Ubuntu 22.04, but success in Windows using visual studio 2022. #99

@moh-hassan

Description

@moh-hassan

A multi target project net6, net472 with c# 12 is developed to support both windows and Linux.
<LangVersion>12</LangVersion>

i use global.json that allow sdk6:

{
  "sdk": {
    "version": "6.0.419",
    "rollForward": "latestFeature"
  }
}

When the project is built in windows 11 using visual studio v17.9.2 , it is compiled without errors.

Note: visual studio 2022 v 17.9.2 auto install net8 (that support c# 12). So it is expected to success compilation

When the project is built in In Ubuntu 22.04 (with Mono 6 installed), using the command dotnet build , the compiler raise error:

CSC : error CS1617: Invalid option '12' for /langversion. Use '/langversion:?' to list supported values. 

Resolving the issue:

I had to install net8 sdk (8.0.200) with runtime in Ubuntu 22.04 to build the project and modify the global.json.
Then rebuild. The build success without errors:

{
  "sdk": {
    "version": "8.0.200",
    "rollForward": "latestFeature"
  }
}

It seems that c# 12 support need net8 to be installed in UbUntu 22.04. (or windows)

I suggest, this limitation can be documented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions