Skip to content
12 changes: 9 additions & 3 deletions scripts/dotnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def get_target_framework_moniker(framework: str) -> str:
return 'net8.0'
if framework == 'nativeaot9.0':
return 'net9.0'
if framework == 'nativeaot10.0':
return 'net10.0'
else:
return framework

Expand Down Expand Up @@ -119,7 +121,7 @@ class VersionsAction(Action):
def __call__(self, parser, namespace, values, option_string=None):
if values:
for version in values:
if not search(r'^\d\.\d+\.\d+', version):
if not search(r'^\d+\.\d+\.\d+', version):
raise ArgumentTypeError(
'Version "{}" is in the wrong format'.format(version))
setattr(namespace, self.dest, values)
Expand Down Expand Up @@ -528,7 +530,7 @@ def run(self,
FrameworkVersion = NamedTuple('FrameworkVersion', major=int, minor=int)
@tracer.start_as_current_span("dotnet_get_framework_version") # type: ignore
def get_framework_version(framework: str) -> FrameworkVersion:
groups = search(r".*(\d)\.(\d)$", framework)
groups = search(r".*(\d+)\.(\d+)$", framework)
if not groups:
raise ValueError("Unknown target framework: {}".format(framework))

Expand Down Expand Up @@ -594,12 +596,16 @@ def get_dotnet_version_from_path(
# Attempt 2: Increase the minor version by 1 and retry.
sdk = next((f for f in sdks if f.startswith(
"{}.{}".format(version.major, version.minor + 1))), None)
if not sdk:
if version.major == 9:
sdk = next((f for f in sdks if f.startswith("10.0")), None)
if not sdk:
sdk = next((f for f in sdks if f.startswith(
"{}.{}".format('6', '0'))), None)
if not sdk:
raise RuntimeError(
"Unable to determine the .NET SDK used for {}".format(framework)
f"Unable to determine the .NET SDK used for {framework}. "
f"SDKs found in {sdk_path}: {sdks}. Major version: {version.major}"
)

return sdk
Expand Down
Loading