Skip to content

dotnet new global.json --sdk-version incorrectly accepts invalid SDK versions like 9.0.x, emit error instead #50460

@Frulfump

Description

@Frulfump

Is your feature request related to a problem? Please describe.

Since dotnet/runtime#118418 adds a warning in dotnet --info for invalid version strings in .NET 10, let's stop one vector where you can add an invalid version string since not everyone will run dotnet --info.

The invalid version formats:
9 i.e ^\d+$
9.0 i.e ^\d+.\d+$
9.0.0 i.e ^\d+.\d+.\d+$
9.0.x i.e ^\d+.\d+.[xX]$

and only allow the format 9.0.100 i.e ^\d+.\d+.(?:[1-9]\d{2})$

(Note: \d allows non 0-9 digits i.e digits from other "languages" so would be better to be explicit and only allow the range 0-9)

Describe the solution you'd like

Ideally error on invalid version strings, maybe provide a way to force it.

Additional context

Ref: #49816
Ref: dotnet/runtime#118418 adding a warning for dotnet --info

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions