{"id":5855,"date":"2017-02-25T06:03:13","date_gmt":"2017-02-24T22:03:13","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/heaths\/?p=3785"},"modified":"2019-02-17T15:29:20","modified_gmt":"2019-02-17T22:29:20","slug":"vswhere-available","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/setup\/vswhere-available\/","title":{"rendered":"vswhere Available"},"content":{"rendered":"<p>After feedback on the <a href=\"https:\/\/blogs.msdn.microsoft.com\/heaths\/2017\/01\/25\/visual-studio-setup-powershell-module-available\/\">VSSetup PowerShell module<\/a> to query Visual Studio 2017 and related products, I&#8217;m pleased to say that a native, single-file executable is available on GitHub: <a href=\"https:\/\/github.com\/Microsoft\/vswhere\">vswhere<\/a>. The VSSetup PowerShell module is also <a href=\"https:\/\/github.com\/Microsoft\/vssetup.powershell\">available<\/a> on GitHub and provides a number of benefits for PowerShell scripts, but build tools and CMake and deployment scripts wanted a simple executable they could redistribute without spawning PowerShell.<\/p>\n<p>You can enumerate instances with optional demands on which products, workloads, and components; and on which versions you require. Results can be printed in a variety of formats &#8211; currently colon-delimited plain text and JSON. If the query API isn&#8217;t registered, rather than erring no instances are assumed to be installed and results are empty, e.g. an empty array for JSON.<\/p>\n<h3>Example<\/h3>\n<p>In a batch build script you could, for example, find MSBuild 15.0 by finding the latest, newest instance with MSBuild installed.<\/p>\n<p>[code]@echo off<\/p>\n<p>set pre=Microsoft.VisualStudio.Product.\nset ids=%pre%Community %pre%Professional %pre%Enterprise %pre%BuildTools<\/p>\n<p>for \/f &quot;usebackq tokens=1* delims=: &quot; %%i in (`vswhere -latest -products %ids% -requires Microsoft.Component.MSBuild -version [15.0,16.0)`) do (\n  if \/i &quot;%%i&quot;==&quot;installationPath&quot; set InstallDir=%%j\n)<\/p>\n<p>if exist &quot;%InstallDir%\\MSBuild\\15.0\\Bin\\MSBuild.exe&quot; (\n  &quot;%InstallDir%\\MSBuild\\15.0\\Bin\\MSBuild.exe&quot; %*\n)[\/code]<\/p>\n<p>You can find more <a href=\"https:\/\/github.com\/Microsoft\/vswhere\/wiki\/Examples\">examples<\/a> in our <a href=\"https:\/\/github.com\/Microsoft\/vswhere\/wiki\">wiki<\/a>.<\/p>\n<h3>Usage<\/h3>\n<p>Current usage follows.<\/p>\n<p>[code gutter=&#8221;false&#8221;]Visual Studio Locator, version 1.0.14-beta\nCopyright (C) Microsoft Corporation. All rights reserved.<\/p>\n<p>Usage: vswhere.exe [options]<\/p>\n<p>Options:\n  -all           Finds all instances regardless if they are complete.\n  -products arg  One or more products to find. Defaults to Community, Professional, and Enterprise.\n  -requires arg  One or more workloads or components required when finding instances.\n  -version arg   A version range for instances to find. Example: [15.0,16.0) will find versions 15.*.\n  -latest        Return only the newest version and last installed.\n  -format arg    Return information about instances found in a format described below.\n  -nologo        Do not show logo information. Some formats noted below will not show a logo anyway.\n  -?, -h, -help  Display this help message.<\/p>\n<p>Formats:\n  json           Colon-delimited properties in separate blocks for each instance (default).\n  text           An array of JSON objects for each instance (no logo).[\/code]<\/p>\n<p>Download the latest from our <a href=\"https:\/\/github.com\/Microsoft\/vswhere\/releases\">release page<\/a> and give us <a href=\"https:\/\/github.com\/Microsoft\/vswhere\/issues\">feedback<\/a> on what common tasks you would like supported. Please also consider contributing examples to the <a href=\"https:\/\/github.com\/Microsoft\/vswhere\/wiki\">wiki<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After feedback on the VSSetup PowerShell module to query Visual Studio 2017 and related products, I&#8217;m pleased to say that a native, single-file executable is available on GitHub: vswhere. The VSSetup PowerShell module is also available on GitHub and provides a number of benefits for PowerShell scripts, but build tools and CMake and deployment scripts [&hellip;]<\/p>\n","protected":false},"author":389,"featured_media":3843,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[14,45,46,57],"class_list":["post-5855","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-development","tag-visual-studio","tag-vs","tag-vs2017"],"acf":[],"blog_post_summary":"<p>After feedback on the VSSetup PowerShell module to query Visual Studio 2017 and related products, I&#8217;m pleased to say that a native, single-file executable is available on GitHub: vswhere. The VSSetup PowerShell module is also available on GitHub and provides a number of benefits for PowerShell scripts, but build tools and CMake and deployment scripts [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/5855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/users\/389"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/comments?post=5855"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/5855\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media\/3843"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media?parent=5855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/categories?post=5855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/tags?post=5855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}