Repository navigation
Expand file tree
/
Copy pathVsShellInfo.cs
More file actions
54 lines (45 loc) · 1.78 KB
/
Copy pathVsShellInfo.cs
File metadata and controls
54 lines (45 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
namespace NuGet.VisualStudio
{
[PartCreationPolicy(CreationPolicy.Shared)]
[Export(typeof(IVsShellInfo))]
public class VsShellInfo : IVsShellInfo
{
private const int ExpressSku = 500;
private const int WindowsSubSku = 0x4000;
private readonly Lazy<bool> _isVisualStudioExpressForWindows8Thunk = new Lazy<bool>(ShellIsVisualStudioExpressForWindows8);
public bool IsVisualStudioExpressForWindows8
{
get { return _isVisualStudioExpressForWindows8Thunk.Value; }
}
private static bool ShellIsVisualStudioExpressForWindows8()
{
if (VsVersionHelper.VsMajorVersion < 11)
{
// We only care for the Dev11 or above version of the express SKU.
return false;
}
var vsShell = ServiceLocator.GetGlobalService<SVsShell, IVsShell>();
if (vsShell == null)
{
return false;
}
object skuValue;
var isExpress = ErrorHandler.Succeeded(vsShell.GetProperty((int)__VSSPROPID2.VSSPROPID_SKUEdition, out skuValue)) && skuValue is int && (int)skuValue == ExpressSku;
if (!isExpress)
{
return false;
}
object subSkuValue;
var isWindows = ErrorHandler.Succeeded(vsShell.GetProperty((int)__VSSPROPID2.VSSPROPID_SubSKUEdition, out subSkuValue)) && subSkuValue is int && (int)subSkuValue == WindowsSubSku;
if (!isWindows)
{
return false;
}
return true;
}
}
}