Skip to content

Versions

Heath Stewart edited this page Sep 29, 2023 · 2 revisions

The version range syntax is the same as that used by both VSIX and NuGet, and described below:

  • A version range is a comma-separated list of minimum and maximum version numbers, e.g. [1.0, 2.0).
  • A version is 2 to 4 period-separated numbers, i.e. Windows version number, e.g. 1.2, 1.2.3, or 1.2.3.4.
  • [ means the minimum version is inclusive of the specified version.
  • ] means the maximum version is inclusive of the specified version.
  • ( means the minimum version is exclusive of the specified version.
  • ) means the maximum version is exclusive of the specified version.
  • A single version number, e.g. 1.2, means that version or newer. It's equivalent to [1.2, ).
  • If the minimum version is not specified, it's equivalent to 0.0.
  • If the maximum version is not specified, it's equivalent to 65535.65535.65535.65535.

For a list of what is supported to pass to -requires, browse the workload and component IDs on MSDN.

Escape versions in batch scripts

The version range may cause issues in batch scripts when used in for loops and needs to be escaped. Following are two approaches:

  • When hardcoding a version, you can use ^ to escape ,, (, and ):

    @echo off
    set toolpath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
    for /f "usebackq tokens=*" %%i in (`%toolpath% -version [15^,17^) -property installationPath`) do (
      echo %%i
    )
  • If the version is defined as a variable, you can use delayed expansion:

    @echo off
    setlocal enabledelayedexpansion
    set toolpath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
    set version=[15,17)
    for /f "usebackq tokens=*" %%i in (`%toolpath% -version !version! -property installationPath`) do (
      echo %%i
    )

Release versions

The table below lists the corresponding major version for the each year in the Visual Studio product name.

Year Version
Visual Studio 2017 15.0
Visual Studio 2019 16.0
Visual Studio 2022 17.0