Microsoft Visual Studio 2017 and newer uses a new setup engine that allows multiple instances to be installed quickly and in different configuration. To enumerate these instances and find one that fulfills your requirements, the Setup Configuration API provides a set of interface. This crate provides a safe and idiomatic wrapper for Go.
First install the heaths/go-vssetup module:
go get github.com/heaths/go-vssetup
You can then use the vssetup
module to enumerate instances:
// Enumerate launchable instances.
instances, _ := vssetup.Instances(false)
for _, instance := range instances {
if installationPath, err := instance.InstallationPath(); err == nil {
fmt.Println("InstallationPath =", installationPath)
}
}
While this project is not meant to replace the official vswhere that ships with Visual Studio and is available in some package managers, nor is it meant to be fully compatible with all official vswhere options, this project does have a vswhere
command that allows you to quickly see this module in action:
go run ./cmd/vswhere
You can also download a binary from releases. It is not call-compatible with the official vswhere.
-
On what platforms does this work?
This module should compile on any platform but will only return available instances on Windows if Visual Studio 2017 or newer is installed.
-
Is this project supported by Microsoft?
Though I am the developer who wrote the Setup Configuration API while working for Microsoft, this module is unsupported by Microsoft.