Skip to content

Examples

Heath Stewart edited this page Nov 15, 2022 · 14 revisions

vswhere.exe has been designed to be a flexible option to finding Visual Studio and other products like our standalone Build Tools. It can emit information in a variety of output formats to support a wide range of build and deployment tooling, such as batch scripts, make files, and PowerShell scripts - though in the latter case, I recommend you check out VSSetup.PowerShell for a more PowerShell-friendly option with even more capability than vswhere.

The following are merely useful examples for a variety of targeted scenarios. Contributions via pull requests for other common scenarios are welcome.

For each of these examples, all versions of Visual Studio or other installed products instance are searched. You can always pass -version [15.0,16.0) to limit your searches to a particular version. In this example, only 15.x versions will be searched. Read about Versions for more ways to specify a version range.

Components

To find an instance or instances that have required workloads or components installed, you can pass any number to -requires. By default, all specified IDs must be installed for an instance to be selected. If you want to select instances with any of those IDs installed, pass -requiresAny.

See https://aka.ms/vs/workloads for a list of workloads and components with descriptions.

Wildcards

New with version 3.1.1 you can also use wildcards:

  • ? matches any one character
  • * matches zero or more of any characters

For example, if you need to find an instance with any Windows 10 SDK installed, you could call:

vswhere -requires Microsoft.VisualStudio.Component.Windows10SDK.*