diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 651b1a9f49..0000000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,51 +0,0 @@ -# TODO: Line 47, enable pytest --doctest-modules - -name: Tests -on: [push, pull_request] -jobs: - Tests: - strategy: - fail-fast: false - max-parallel: 15 - matrix: - node: [10.x, 12.x, 14.x] - python: [3.6, 3.8, 3.9] - os: [macos-latest, ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node }} - - name: Use Python ${{ matrix.python }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - env: - PYTHON_VERSION: ${{ matrix.python }} - - name: Install Dependencies - run: | - npm install --no-progress - pip install flake8 pytest - - name: Set Windows environment - if: matrix.os == 'windows-latest' - run: - echo '::set-env name=GYP_MSVS_VERSION::2015' - echo '::set-env name=GYP_MSVS_OVERRIDE_PATH::C:\\Dummy' - - name: Lint Python - if: matrix.os == 'ubuntu-latest' - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Run Python tests - run: | - python -m pytest - # - name: Run doctests with pytest - # run: python -m pytest --doctest-modules - - name: Run Node tests - run: | - npm test diff --git a/lib/Find-VisualStudio.cs b/lib/Find-VisualStudio.cs index d2e45a7627..f1070d3f55 100644 --- a/lib/Find-VisualStudio.cs +++ b/lib/Find-VisualStudio.cs @@ -10,6 +10,7 @@ using System.Text; using System.Runtime.InteropServices; using System.Collections.Generic; +using System.Text.RegularExpressions; namespace VisualStudioConfiguration { @@ -196,12 +197,13 @@ public static void PrintJson() int pceltFetched; ISetupInstance2[] rgelt = new ISetupInstance2[1]; List instances = new List(); + while (true) { e.Next(1, rgelt, out pceltFetched); if (pceltFetched <= 0) { - Console.WriteLine(String.Format("[{0}]", string.Join(",", instances.ToArray()))); + Console.Write(String.Format("[{0}]", string.Join(",", instances.ToArray()))); return; } @@ -216,6 +218,25 @@ public static void PrintJson() } } + private static string CheckInstance(ISetupPackageReference package) + { + // Visual Studio Community 2017 component directory: + // https://www.visualstudio.com/en-us/productinfo/vs2017-install-product-Community.workloads + String Win10SDKVer = null; + + const string Win10SDKPrefix = "Microsoft.VisualStudio.Component.Windows10SDK."; + String id = package.GetId(); + if (id.StartsWith(Win10SDKPrefix)) + { + String[] parts = id.Substring(Win10SDKPrefix.Length).Split('.'); + String foundSdkVer = parts[4]; + Win10SDKVer = String.Compare(Win10SDKVer, foundSdkVer) > 0 ? Win10SDKVer : foundSdkVer; + return String.Format("{0}.{1}", id, Win10SDKVer); + } + // "Microsoft.VisualStudio.Component.Windows81SDK" as well + return id; + } + private static string JsonString(string s) { return "\"" + s.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\""; @@ -225,7 +246,6 @@ private static string InstanceJson(ISetupInstance2 setupInstance2) { // Visual Studio component directory: // https://docs.microsoft.com/en-us/visualstudio/install/workload-and-component-ids - StringBuilder json = new StringBuilder(); json.Append("{"); @@ -238,13 +258,41 @@ private static string InstanceJson(ISetupInstance2 setupInstance2) List packages = new List(); foreach (ISetupPackageReference package in setupInstance2.GetPackages()) { - string id = JsonString(package.GetId()); + string id = JsonString(CheckInstance(package)); packages.Add(id); } - json.Append(String.Format("\"packages\":[{0}]", string.Join(",", packages.ToArray()))); + json.Append(String.Format("\"packages\":[{0}", string.Join(",", packages.ToArray()))); + + String jsonResultString = json.ToString(); + if (!jsonResultString.Contains("Windows10SDK")) + { + System.Diagnostics.Process cmd = new System.Diagnostics.Process(); + cmd.StartInfo.FileName = "cmd.exe"; + cmd.StartInfo.RedirectStandardInput = true; + cmd.StartInfo.RedirectStandardOutput = true; + cmd.StartInfo.CreateNoWindow = true; + cmd.StartInfo.UseShellExecute = false; + cmd.Start(); + + cmd.StandardInput.WriteLine("@echo off"); + cmd.StandardInput.Flush(); + cmd.StandardInput.WriteLine( + String.Format("{0}\\VC\\Auxiliary\\Build\\vcvarsall.bat x64", path) + ); + cmd.StandardInput.Flush(); + cmd.StandardInput.WriteLine("@echo %UCRTVersion%"); + cmd.StandardInput.Flush(); + cmd.StandardInput.Close(); + cmd.WaitForExit(); + String SDKFullText = cmd.StandardOutput.ReadToEnd(); + int pos = SDKFullText.IndexOf("[Version "); + String SDKVersion = SDKFullText.Substring(pos + 14, 5); + json.Append(String.Format(",\"Microsoft.VisualStudio.Component.Windows10SDK.{0}\"", SDKVersion)); + cmd.Close(); + } + json.Append("]}"); - json.Append("}"); return json.ToString(); } } -} +} \ No newline at end of file