Run parts of test_script only on Visual Studio 2017 image?

Jan Pio's Avatar

Jan Pio

14 Feb, 2018 02:23 PM

I have several "steps" in my test_script that only work if Visual Studio 2017 is installed, to be specific:

  - "\"%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer\\vswhere\" -property installationPath -products * -all"
  - "\"%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer\\vswhere\" -property installationPath -all"
  - "\"%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer\\vswhere\" -property installationPath -legacy"

Is there a way to run those only on the VIsual Studio 2017 image, and not on the VS2015 one where it will crash as the file doesn't exist?

Thanks, Jan

  1. 1 Posted by Ilya Finkelshte... on 14 Feb, 2018 07:40 PM

    Ilya Finkelshteyn's Avatar

    There are many ways to do so. You can condition your script with APPVEYOR_BUILD_WORKER_IMAGE Environment variable or use test-path PowerShell command to check that file exists. Or similar command in CMD.

  2. 2 Posted by Jan Pio on 14 Feb, 2018 10:46 PM

    Jan Pio's Avatar

    Ah, that simple:

      - IF NOT EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" ( echo "no vswhere" ) ELSE "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -property installationPath -products * -all"
      - IF NOT EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" ( echo "no vswhere" ) ELSE "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -property installationPath -all"
      - IF NOT EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" ( echo "no vswhere" ) ELSE "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -property installationPath -legacy"
    

    Not pretty but does the job. Thanks.

  3. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:27 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac