Skip to content

Commit

Permalink
(chocolatey#2754) Add support for detecting newer Windows versions
Browse files Browse the repository at this point in the history
This allows Chocolatey CLI to detect Windows 11, Server 2019 and Server 2022.
Which will allow the OS_NAME environment variable to be set correctly on those
operating systems.
  • Loading branch information
TheCakeIsNaOH committed Jul 1, 2023
1 parent d836138 commit 4bb8167
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/chocolatey/infrastructure/platforms/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,15 @@ private static string GetWindowsVersionName(Version version)
switch (majorMinor)
{
case "10.0":
name = isServer ? "Windows Server 2016" : "Windows 10";
if (isServer)
{
name = (version.Build < 20348) ? (version.Build < 17763) ?
"Windows Server 2016" : "Windows Server 2019" : "Windows Server 2022";
}
else
{
name = (version.Build < 22000) ? "Windows 10" : "Windows 11";
}
break;
case "6.4":
name = isServer ? "Windows Server 2016" : "Windows 10";
Expand Down

0 comments on commit 4bb8167

Please sign in to comment.