ilammy / msvc-dev-cmd

GitHub Action to setup Developer Command Prompt for Microsoft Visual C++
MIT License
329 stars 44 forks source link

How to specify exact version number rather than latest #68

Open SSoelvsten opened 10 months ago

SSoelvsten commented 10 months ago

I am on https://github.com/thomasmoelhave/tpie/pull/257 , adding CI for all major platforms for the TPIE library which my research project is heavily dependent upon. Yet, due to a very weird error (https://github.com/thomasmoelhave/tpie/issues/269), the library cannot compile with the latest 2019 MSC compiler, but only up to 19.27.

Specifically, as far as I can tell, the TPIE compatibility with MSC breaks between these two version numbers

Working Failing
Product Version 16.7 16.8.1
Runtime Library 14.27 14.28
MSC version 19.27.29112 19.28.29333

Based on the README, I am unable to figure out what value to parse to this GitHub Action? There is a toolset argument but I seem to get an error regardless of whether I set it to 16.7, 14.27 or 19.27 (or maybe I missed a specific value when trying it out?).

For example when using v1.12.1 and toolset to the product version, I get the error messages

Found with vswhere: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
Error: Could not setup Developer Command Prompt: invalid parameters
[ERROR:vcvars.bat] Toolset directory for version '16.7' was not found.

Based on the Wikipedia article, I should provide a truncated runtime library instead, but neither 14.27 nor 141 seem to work.

SSoelvsten commented 10 months ago

Maybe all this boils down to "How do I derive the toolset number?" which in itself might be worth adding to the README.

pzhlkj6612 commented 10 months ago

Hi! I've not dug into the issues you link but still want to share something with you.

I've tested GitHub Actions with the following workflow file:

name: CI
on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  workflow_dispatch:
jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [windows-2019, windows-2022]
        toolset_ver:
          - "v140"
          - "v141"
          - 140
          - 141
          - 14
          - "14.0"
          - 14.1
          - 14.2
          - 14.21
          - 14.22
          - 14.23
          - 14.24
          - 14.25
          - 14.26
          - 14.27
          - 14.28
          - 14.29
          - "14.30"
          - 14.3
          - 14.31
          - 14.32
          - 14.33
          - 14.34
          - 14.35
          - 14.36
          - 14.37
          - 14.38
    steps:
      - uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: x64
          toolset: ${{ matrix.toolset_ver }}
      # https://learn.microsoft.com/cpp/build/reference/help-compiler-command-line-help
      - run: |
          "CL_VERSION=$(cl /? 2>&1 | Select-String -Pattern 'Compiler Version' -CaseSensitive -SimpleMatch)" | Out-File -Append -FilePath ${env:\GITHUB_OUTPUT}
        shell: pwsh
        id: cl
      - run: echo '::warning ::${{ matrix.os }} + toolset-${{ matrix.toolset_ver }} = ${{ steps.cl.outputs.CL_VERSION }}'

The result is:

toolset windows-2019 windows-2022 note
14 19.29.30152 19.37.32824
14.0 19.00.24247.2 140
14.1 19.16.27051 19.16.27051 v141
14.2 19.29.30152 19.29.30152
14.25 19.25.28614
14.29 19.29.30152 19.29.30152
14.3 19.37.32824
14.35 19.35.32217.1
14.37 19.37.32824

(The above table is generated by TablesGenerator.com)

The versions of toolset are from the "windowsNNNN-readme.md" files in https://github.com/actions/runner-images/tree/main/images/win . Please search "Microsoft.VisualStudio.Component.VC" in those files.

SSoelvsten commented 10 months ago

That looks like the exact information I needed, thanks! :slightly_smiling_face: