.net core 可以在 WSL 执行时检测到 OS 吗?

Can .net core detect OS on WSL execution?

我在 SO 上找到的以下代码在运行时检测 Windows,但它认为 WSL Ubuntu 是 Windows。有什么更好的办法吗?或者?

public static bool IsWindows
{
    get
    {
        var osver = Environment.OSVersion;
        return osver.Platform == PlatformID.Win32NT;
    }
}

卫生部!我是 运行 由 Visual Studio 构建的 EXE,WSL 检测到它并像在 Windows 控制台中一样运行它。在 Ubuntu 上构建,它创建一个 linux 可执行文件。