-
Notifications
You must be signed in to change notification settings - Fork 99
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
, or1.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.
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 )
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 |
Copyright (C) Microsoft Corporation. All rights reserved. Licensed under the MIT license. See LICENSE.txt in the project root for license information.