From fd7f8754b3c8807d39dcf8295a12ff32ec0264b4 Mon Sep 17 00:00:00 2001
From: "Painter, Christopher P" <chrpai@iswix.com>
Date: Thu, 20 Dec 2018 13:57:18 -0600
Subject: VS2019 Support

---
 src/ca/vsca.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

(limited to 'src/ca')

diff --git a/src/ca/vsca.cpp b/src/ca/vsca.cpp
index 30174672..ac045db8 100644
--- a/src/ca/vsca.cpp
+++ b/src/ca/vsca.cpp
@@ -47,6 +47,12 @@ static HRESULT ProcessVS2017(
     __in BOOL fComplete
     );
 
+static HRESULT ProcessVS2019(
+    __in_opt ISetupInstance* pInstance,
+    __in DWORD64 qwVersion,
+    __in BOOL fComplete
+);
+
 static HRESULT SetPropertyForComponent(
     __in DWORD cComponents,
     __in VS_COMPONENT_PROPERTY* rgComponents,
@@ -56,6 +62,7 @@ static HRESULT SetPropertyForComponent(
 static VS_INSTANCE vrgInstances[] =
 {
     { FILEMAKEVERSION(15, 0, 0, 0), FILEMAKEVERSION(15, 0xffff, 0xffff, 0xffff), ProcessVS2017 },
+    { FILEMAKEVERSION(16, 0, 0, 0), FILEMAKEVERSION(16, 0xffff, 0xffff, 0xffff), ProcessVS2019 },
 };
 
 /******************************************************************
@@ -407,6 +414,80 @@ LExit:
     return hr;
 }
 
+static HRESULT ProcessVS2019(
+    __in_opt ISetupInstance* pInstance,
+    __in DWORD64 qwVersion,
+    __in BOOL fComplete
+)
+{
+    static ISetupInstance* pLatest = NULL;
+    static DWORD64 qwLatest = 0;
+
+    static LPCWSTR rgwzProducts[] =
+    {
+        L"Microsoft.VisualStudio.Product.Community",
+        L"Microsoft.VisualStudio.Product.Professional",
+        L"Microsoft.VisualStudio.Product.Enterprise",
+    };
+
+    // TODO: Consider making table-driven with these defaults per-version for easy customization.
+    static VS_COMPONENT_PROPERTY rgComponents[] =
+    {
+        { L"Microsoft.VisualStudio.Component.FSharp", L"VS2019_IDE_FSHARP_PROJECTSYSTEM_INSTALLED" },
+        { L"Microsoft.VisualStudio.Component.Roslyn.LanguageServices", L"VS2019_IDE_VB_PROJECTSYSTEM_INSTALLED" },
+        { L"Microsoft.VisualStudio.Component.Roslyn.LanguageServices", L"VS2019_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED" },
+        { L"Microsoft.VisualStudio.Component.TestTools.Core", L"VS2019_IDE_VSTS_TESTSYSTEM_INSTALLED" },
+        { L"Microsoft.VisualStudio.Component.VC.CoreIde", L"VS2019_IDE_VC_PROJECTSYSTEM_INSTALLED" },
+        { L"Microsoft.VisualStudio.Component.Web", L"VS2019_IDE_VWD_PROJECTSYSTEM_INSTALLED" },
+        { L"Microsoft.VisualStudio.PackageGroup.DslRuntime", L"VS2019_IDE_MODELING_PROJECTSYSTEM_INSTALLED" },
+    };
+
+    HRESULT hr = S_OK;
+
+    if (fComplete)
+    {
+        if (pLatest)
+        {
+            hr = ProcessInstance(pLatest, L"VS2019_ROOT_FOLDER", countof(rgComponents), rgComponents);
+            ExitOnFailure(hr, "Failed to process VS2019 instance.");
+        }
+    }
+    else if (pInstance)
+    {
+        hr = InstanceInProducts(pInstance, countof(rgwzProducts), rgwzProducts);
+        ExitOnFailure(hr, "Failed to compare product IDs.");
+
+        if (S_FALSE == hr)
+        {
+            ExitFunction();
+        }
+
+        hr = InstanceIsGreater(pLatest, qwLatest, pInstance, qwVersion);
+        ExitOnFailure(hr, "Failed to compare instances.");
+
+        if (S_FALSE == hr)
+        {
+            ExitFunction();
+        }
+
+        ReleaseNullObject(pLatest);
+
+        pLatest = pInstance;
+        qwLatest = qwVersion;
+
+        // Caller will do a final Release() otherwise.
+        pLatest->AddRef();
+    }
+
+LExit:
+    if (fComplete)
+    {
+        ReleaseObject(pLatest);
+    }
+
+    return hr;
+}
+
 static HRESULT SetPropertyForComponent(
     __in DWORD cComponents,
     __in VS_COMPONENT_PROPERTY* rgComponents,
-- 
cgit v1.2.3-55-g6feb