
For most modern computers, the most recent.

In the following figure, for example, you can see v2.0, v3.0, v3.5 and v4.8 installed on the computer. NET Framework versions installed on your computer (Your computer can have multiple versions of. Get-ChildItem ‘HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP’ -Recurse | Get-ItemProperty -Name version -EA 0 | Where | Select PSChildName, version Then Powershell will open as administrator.Ģ) At the PowerShell window, type the following command (you can copy and paste the command), then press Enter: Here’s how to do it:ġ) Right-click on the Start menu button at the bottom corner of the desktop and select Windows Powershell (Admin). NET Framework version installed on your computer. You can easily use PowerShell to check the. Public static bool isLinux() =>RuntimeInformation.IsOSPlatform(OSPlatform.Linux) Īnd this way we use our generalize method to detect Operating System in Dot.Net CoreĬonsole.How to check. Public static bool isMacOS() =>RuntimeInformation.IsOSPlatform(OSPlatform.OSX) Public static bool isWindows() =>RuntimeInformation.IsOSPlatform(OSPlatform.Windows) So our final code looks like as written below. }Finally, with Runtime.InteropServices we able to detect Operating System in the Dot.Net Core application.įurther, we can generalize this method programmatically to use it in our project which tells us the current OS platform. } # For Linux var isLinux=.IsOSPlatform(OSPlatform.Linux) Ĭonsole.WriteLine("Hello, this is Linux") #Similarly, we can check for Mac var isOSX=.IsOSPlatform(OSPlatform.OSX) Ĭonsole.WriteLine("Hello, this is Mac OS") #Code For Windows var isWindows=.IsOSPlatform(OSPlatform.Windows) Ĭonsole.WriteLine("Hello, this is windows") OSPlatform defines three static propertiesĬode: To determine OS platform in DotNet Core.


Runtime.InteropServices: Provides APIs to query about runtime and OS. NET Core app is running on Mac or Windows?įinally, with a little Google, I came to know about InteropServices.RuntimeInformation. NET CORE Environment.OSVersion is not working so I was like how to determine whether my. Net Framework by using Environment.OSVersion very easily we can detect the Operating System. i.e Windows Operating System, OSX Operating System, or on Linux Operating System, and based on OS platform have to do further logic. There is a requirement in one of my applications where I have to detect the operating system. NET Core: Here in this article will learn how to get the operating system details on which our.
