Apperently there's also System.Runtime.InteropServices.RuntimeInformation
now.
PROPERTIES
FrameworkDescription
Gets the name of the .NET installation on which an app is running.
OSArchitecture
Gets the platform architecture on which the current app is running.
OSDescription
Gets a string that describes the operating system on which the app is running.
ProcessArchitecture
Gets the process architecture of the currently running app.
RuntimeIdentifier
Gets the platform on which an app is running.
https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.runtimeinformation?view=net-6.0
using System;
public class Program
{
public static void Main()
{
Console.WriteLine(System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription);
Console.WriteLine(System.Runtime.InteropServices.RuntimeInformation.OSArchitecture);
Console.WriteLine(System.Runtime.InteropServices.RuntimeInformation.OSDescription);
Console.WriteLine(System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture);
Console.WriteLine(System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier);
}
}
.NET 6.0.0-rtm.21522.10
X64
Linux 5.4.0-1064-azure #67~18.04.1-Ubuntu SMP Wed Nov 10 11:38:21 UTC 2021
X64
debian.11-x64
https://dotnetfiddle.net/sZ3OKj
Funnily enough this doesn't seem to work in powershell, at least not for me when trying to run: [System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier