OSVersionExt 4.0.0
dotnet add package OSVersionExt --version 4.0.0
NuGet\Install-Package OSVersionExt -Version 4.0.0
<PackageReference Include="OSVersionExt" Version="4.0.0" />
<PackageVersion Include="OSVersionExt" Version="4.0.0" />
<PackageReference Include="OSVersionExt" />
paket add OSVersionExt --version 4.0.0
#r "nuget: OSVersionExt, 4.0.0"
#:package OSVersionExt@4.0.0
#addin nuget:?package=OSVersionExt&version=4.0.0
#tool nuget:?package=OSVersionExt&version=4.0.0
Windows Version & Edition Detection Library for C# .NET
Determining the Windows version and edition can be challenging.
First, the System.Environment.OSVersion.Version property in the .NET Framework up to version 4.8.1 and in .NET Core up to version 3.1 returns incorrect results on Windows 10 and later versions. In addition, correctly identifying the Windows edition, such as distinguishing between Windows 10 and Windows 11, adds another layer of complexity, as it requires handling build numbers.
This library abstracts all of these challenges. It returns the detected Windows edition as a strongly typed enum, without the need to deal with ambiguous string representations.
It works out of the box on Windows 11, Windows 10, Windows Server 2022, and Windows Server 2019, and also supports earlier Windows versions.
Also available on NuGet: https://www.nuget.org/packages/OSVersionExt/
<img src="images/windows11-version-demo.png">
using OSVersionExtension;
Console.WriteLine($"Windows version: " +
$"{OSVersion.GetOSVersion().Version.Major}." +
$"{OSVersion.GetOSVersion().Version.Minor}." +
$"{OSVersion.GetOSVersion().Version.Build}" +
$"");
Console.WriteLine($"OS type: {OSVersion.GetOperatingSystem()}");
Console.WriteLine($"is workstation: {OSVersion.IsWorkstation}");
Console.WriteLine($"is server: {OSVersion.IsServer}");
Console.WriteLine($"64-Bit OS: {OSVersion.Is64BitOperatingSystem}");
if (OSVersion.GetOSVersion().Version.Major >= 10)
{
Console.WriteLine($"Windows Display Version: {OSVersion.MajorVersion10Properties().DisplayVersion ?? "(Unable to detect)"}");
Console.WriteLine($"Windows Update Build Revision: {OSVersion.MajorVersion10Properties().UBR ?? "(Unable to detect)"}");
}
Console.ReadKey();
List of detected operating systems
The class can return the OS as an enum.
public enum OperatingSystem
{
Unknown,
Windows2000,
WindowsXP,
WindowsXPProx64,
WindowsHomeServer,
WindowsServer2003,
WindowsServer2003R2,
WindowsVista,
WindowsServer2008,
WindowsServer2008R2,
Windows7,
WindowsServer2012,
Windows8,
Windows81,
WindowsServer2012R2,
WindowsServer2016,
WindowsServer2019,
Windows10,
Windows11,
WindowsServer2022
}
| Operating system | tested | remarks |
|---|---|---|
| Windows 11 | yes | |
| Windows Server 2022 | yes | |
| Windows 10 | yes | 21H2 (build 19044), 21H1 (build 19043), 2009/20H2 (build 19042), 2004 (build 19041), 1909 (build 18363), 1903 (build 18362), 1809 (build 17763) - all x64 |
| Windows Server 2019 | yes | |
| Windows Server 2016 | yes | |
| Windows Server 2012 R2 | yes | |
| Windows 8.1 | yes | x64 |
| Windows 8 | - | |
| Windows 7 | yes | x86 |
| Windows Server 2008 R2 | yes | x64 |
| Windows Server 2008 | - | |
| Windows Vista | - | |
| Windows Server 2003 R2 | yes | |
| Windows Server 2003 | - | |
| Windows Home Server | - | |
| Windows XP 64-Bit Edition | - | |
| Windows XP | - | |
| Windows 2000 | - |
Target framework
This library targets .NET Standard 2.0, ensuring broad cross-platform compatibility. By using .NET Standard, the library can be consumed by multiple .NET implementations, including:
- .NET Framework (version 4.6.1 and later)
- .NET Core (version 2.0 and later)
- .NET 5+
This makes the class usable across different environments without modification, providing maximum flexibility for developers building applications on various platforms. For more details on .NET Standard and supported platforms, please refer to the official documentation: https://learn.microsoft.com/en-us/dotnet/standard/net-standard#?tabs=net-standard-2-0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Win32.Registry (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on OSVersionExt:
| Repository | Stars |
|---|---|
|
freezy/dmd-extensions
A toolbox for virtual pinball dot matrix displays.
|
|
|
mann1x/CPUDoc
|
Updated project to .NET Standard 2.0 and tested with .NET 8.0