Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Standard 2.0 get current Operating System

In .NET Standard 2.0, do I have any ways of determining the operating system and architecture on which my library is running ?

I need to know the OS and architecture to determine which version of nodejs to extract and run at run-time.

Edit about comments : I already found the two methods that you offer but, according to the documentation OperatingSystem.Version and Environment.OSVersion supports the following .net version (standard 2.0 isn't included it seems)

OperatingSystem.version Environement.OSVersion

edit 2 - not a duplicate : As per my first edit above, my question targets .NET Standard 2.0, not .NET Framework or .NET Core. .NET Standard 2.0 is crossplateform byt this page only lists windows version which is a very good way to know that this cannot match my needs.

like image 492
Mathieu VIALES Avatar asked Dec 13 '25 17:12

Mathieu VIALES


1 Answers

RuntimeInformation.IsOSPlatform(OSPlatform.Linux) RuntimeInformation.IsOSPlatform(OSPlatform.OSX) RuntimeInformation.IsOSPlatform(OSPlatform.Windows)

like image 103
Hanabi Avatar answered Dec 16 '25 06:12

Hanabi