abpframework/abp · critical · Exception

Cannot determine runtime platform!

Error message

Cannot determine runtime platform!

What it means

Thrown by PlatformHelper.GetPlatform() — the companion to GetOperatingSystem that collapses the host into the RuntimePlatform enum (Windows vs LinuxOrMacOs). If the OS is not OSX, Linux, or Windows, no enum value applies and a generic Exception is raised.

Source

Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/PlatformHelper.cs:42

        }

        throw new Exception("Cannot determine operating system!");
    }

    public static RuntimePlatform GetPlatform()
    {
        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ||
            RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
        {
            return RuntimePlatform.LinuxOrMacOs;
        }

        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
        {
            return RuntimePlatform.Windows;
        }

        throw new Exception("Cannot determine runtime platform!");
    }
}

public enum RuntimePlatform
{
    Windows = 1,
    LinuxOrMacOs = 2
}

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Run on a supported OS (Windows, Linux, macOS).
  2. Update the .NET runtime so platform detection works.
  3. For other Unix, configure the runtime to report as Linux.
Defensive patterns

Strategy: validation

Validate before calling

static RuntimePlatform? SafePlatform() =>
    (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) ? RuntimePlatform.LinuxOrMacOs
    : RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? RuntimePlatform.Windows
    : null;
var p = SafePlatform() ?? throw new PlatformNotSupportedException("Unsupported OS");

Prevention

When it happens

Trigger: Calling GetPlatform() on a host .NET does not classify as OSX/Linux/Windows. Same root cause as GetOperatingSystem; this method just returns the coarser enum.

Common situations: Same as 224: FreeBSD/Solaris/custom Unix or a misconfigured runtime. This path is hit by code that only needs the binary Windows-vs-Unix distinction (e.g. shell selection).

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/1395db74859ebc9c. Report an issue: GitHub.