Skip to content

dotnet.exe silently ignores global.json with a two-digit sdk version #96299

@maltalex

Description

@maltalex

Describe the bug

dotnet.exe silently ignores global.json with a "wrong" sdk version like "6.0" or "3.1" (as opposed to "6.0.0" or "3.1.0").

To Reproduce

Install .Net SDK, create an empty directory with a global.json file with a two digit SDK version:

{
  "sdk": {
    "version": "6.0"
  }
}

Now, run dotnet --info in the directory and observe output similar to the following:

.NET SDK:
 Version:           8.0.100
 Commit:            57efcf1350
 Workload version:  8.0.100-manifests.6c33ef20

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100\

.NET workloads installed:
 Workload version: 8.0.100-manifests.6c33ef20
There are no installed workloads to display.

Host:
  Version:      8.0.0
  Architecture: x64
  Commit:       5535e31a71

...

global.json file:
  Not found

Note that dotnet reports that global.json hasn't been found. Commands like dotnet --version or dotnet build will silently use the latest SDK instead of requiring .NET 6 as was intended by global.json. The expected behavior in this case would be to either treat "6.0" as "6.0.0" or to show an error to point out the invalid version number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions