Skip to content
Heath Stewart edited this page Mar 4, 2017 · 9 revisions

vswhere.exe is a single-file, native executable you can download or redistribute with your build and deployment environments to locate Visual Studio or other products installed with the new installer for Visual Studio 2017.

By default it will find all complete and launchable (i.e. may have errors but otherwise usable) instances of Visual Studio and return all basic properties in plain text. There are several options to using this program to dictate which products to search, what workloads or components are required, what versions you want, and even the output format. Run the following command to see usage.

vswhere -?

The program can emit localized text to the console using Unicode, but redirecting to a file or piping to another program may require special handling. See our tips on encoding for more detail.

Installing

You can download vswhere.exe from our releases page and redistribute it, or you can install it using a number of other options.

Examples

If you wanted to find MSBuild - now installed under the Visual Studio 2017 and newer installation root - you could script a command like the following to find the latest version installed.

@echo off

for /f "usebackq tokens=1* delims=: " %%i in (`vswhere -latest -requires Microsoft.Component.MSBuild`) do (
  if /i "%%i"=="installationPath" set InstallDir=%%j
)

if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
  "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" %*
)

You can find more examples in our wiki.

Related

We have a number of related projects designed for certain use-cases and that also serve as an example of how to use both the native and managed query APIs.

  • Samples Samples in various programming languages that demonstrates how developers can use the new Visual Studio setup query API.
  • VSIXBootstrapper An installer that can be chained with other packages to locate the latest VSIXInstaller.exe to use for installing VSIX extensions
  • VSSetup.PowerShell PowerShell module to interact with Visual Studio Setup