--- /dev/null
+using System;
+using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.ComTypes;
+
+namespace NaGet.InteropServices
+{
+ /// <summary>
+ /// Windows Os Version
+ /// </summary>
+ public sealed class WindowsVersion
+ {
+ [DllImport("ntdll.dll", SetLastError=true)]
+ private static extern int RtlGetVersion([In, Out] ref OSVERSIONINFOEX lpVersionInformation);
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct OSVERSIONINFOEX
+ {
+ public uint dwOSVersionInfoSize;
+ public uint dwMajorVersion;
+ public uint dwMinorVersion;
+ public uint dwBuildNumber;
+ public uint dwPlatformId;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
+ public string szCSDVersion;
+ public ushort wServicePackMajor;
+ public ushort wServicePackMinor;
+ public ushort wSuiteMask;
+ public char wProductType;
+ public char wReserved;
+ }
+
+ public struct VersionInfo {
+ public uint MajorVersion;
+ public uint MinorVersion;
+ public uint BuildNumber;
+ public ushort ServicePackMajor;
+ public ushort ServicePackMinor;
+ }
+
+ public static VersionInfo? GetVersionInfo() {
+ VersionInfo? retval = null;
+
+ try {
+ OSVERSIONINFOEX versionInformation = new OSVERSIONINFOEX();
+ versionInformation.dwOSVersionInfoSize = (uint)Marshal.SizeOf(versionInformation);
+
+ int result = RtlGetVersion(ref versionInformation);
+ if (result == 0) {
+ VersionInfo info = new VersionInfo();
+ info.MajorVersion = versionInformation.dwMajorVersion;
+ info.MinorVersion = versionInformation.dwMinorVersion;
+ info.BuildNumber = versionInformation.dwBuildNumber;
+ info.ServicePackMajor = versionInformation.wServicePackMajor;
+ info.ServicePackMinor = versionInformation.wServicePackMinor;
+
+ retval = info;
+ }
+ } catch (Exception) {
+ // Drop any exception
+ }
+
+ return retval;
+ }
+ }
+}
VISTA = 160,\r
WIN7 = 161,\r
WIN8 = 162,\r
+ WIN8_1 = 163,\r
+ WIN10 = 164,\r
}\r
\r
public class Platform\r
return PlatformOSType.WIN2003;\r
}\r
} else if (osVer.Major == 6) {\r
- switch (osVer.Minor) {\r
+ int osVerMinor = osVer.Minor;\r
+ NaGet.InteropServices.WindowsVersion.VersionInfo? verInfo = NaGet.InteropServices.WindowsVersion.GetVersionInfo();\r
+ if (verInfo.HasValue) {\r
+ osVerMinor = (int) verInfo.Value.MinorVersion;\r
+ }\r
+ switch (osVerMinor) {\r
case 0:\r
return PlatformOSType.VISTA;\r
case 1:\r
return PlatformOSType.WIN7;\r
case 2:\r
return PlatformOSType.WIN8;\r
+ case 3:\r
+ return PlatformOSType.WIN8_1;\r
+ case 4:\r
+ return PlatformOSType.WIN10;\r
}\r
}\r
break;\r
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
<PropertyGroup>\r
<ProjectGuid>{058E953D-3986-4F74-8516-5A50D267D36A}</ProjectGuid>\r
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
<Compile Include="NaGet.InteropServices\PEFileInfoUtils.cs" />\r
<Compile Include="NaGet.InteropServices\ShellLink.cs" />\r
<Compile Include="NaGet.InteropServices\DownloadScannerService.cs" />\r
+ <Compile Include="NaGet.InteropServices\WindowsVersion.cs" />\r
<Compile Include="NaGet.Packages.Install\DependeciesResolver.cs" />\r
<Compile Include="NaGet.Packages.Install\InstallationLog.cs" />\r
<Compile Include="NaGet.Packages.Install\UpgradeFinder.cs" />\r