vssetup

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 8 Imported by: 0

README

Visual Studio Setup Configuration

releases reference ci

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.

Example

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)
    }
}
vswhere

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.

FAQ

  • 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.

Documentation

Overview

The vssetup package locates installations of Microsoft Visual Studio 2017 and newer, as well as related products installed by the Visual Studio Setup engine on Microsoft Windows. You should be able to compile this package on other platforms, but using any APIs will return a "Not implemented" error.

You can enumerate launchable instances using vssetup.Instances(bool):

instances, _ := vssetup.Instances(false)
for _, instance := range instances {
	if installationPath, err := instance.InstallationPath(); err == nil {
		fmt.Println("InstallationPath =", installationPath)
	}
}

This API wraps the Setup Configuration API, which you can read more about at https://devblogs.microsoft.com/setup/documentation-available-for-the-setup-configuration-api.

These bindings for Go are *unofficial*, despite these APIs being written and maintained by the architect and one of the original developers on the Visual Studio Setup engine and Configuration APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProperties added in v0.4.0

func GetProperties(store PropertyStore) (map[string]interface{}, error)

GetProperties gets all intrinsic properties for an Instance or ErrorState.

func ParseVersion added in v0.3.0

func ParseVersion(s string) (version uint64, err error)

ParseVersion parses a version string like "1.2.3.4" and returns a comparable numeric form.

func ParseVersionRange added in v0.3.0

func ParseVersionRange(s string) (min, max uint64, err error)

ParseVersionRange parses a version range string like "[16.0,)" and returns comparable minimum and maximum numeric forms.

func UserPreferredLanguage added in v0.2.0

func UserPreferredLanguage() language.Tag

UserPreferredLanguage returns the user-preferred language name. On non-Windows system this function always returns "en".

Types

type ErrorState added in v0.3.0

type ErrorState struct {
	// contains filtered or unexported fields
}

ErrorState contains information about failed and skipped packages, as well as log file paths.

func (*ErrorState) Close added in v0.3.0

func (e *ErrorState) Close() error

Close releases any resources used by this Instance immediately.

func (*ErrorState) ErrorLogPath added in v0.3.0

func (e *ErrorState) ErrorLogPath() (string, error)

ErrorLogPath gets the path to the last errors log file if errors were logged.

func (*ErrorState) FailedPackages added in v0.3.0

func (e *ErrorState) FailedPackages() ([]*FailedPackageReference, error)

FailedPackages gets an array of failed package references.

func (*ErrorState) LogPath added in v0.3.0

func (e *ErrorState) LogPath() (string, error)

LogPath gets the path to the last log file.

func (*ErrorState) SkippedPackages added in v0.3.0

func (e *ErrorState) SkippedPackages() ([]*PackageReference, error)

SkippedPackages gets an array of package references that were not installed.

type FailedPackageReference added in v0.3.0

type FailedPackageReference struct {
	PackageReference
	// contains filtered or unexported fields
}

FailedPackageReference describes unique attributes of a failed package.

func (*FailedPackageReference) Action added in v0.3.0

func (p *FailedPackageReference) Action() (string, error)

Action gets the attempted install action for the failed package.

func (*FailedPackageReference) AffectedPackages added in v0.3.0

func (p *FailedPackageReference) AffectedPackages() ([]*PackageReference, error)

AffectedPackages gets the list of packages that were not installed because of this package failure.

func (*FailedPackageReference) Close added in v0.3.0

func (p *FailedPackageReference) Close() error

Close releases any resources used by this FailedPackageReference immediately.

func (*FailedPackageReference) Description added in v0.3.0

func (p *FailedPackageReference) Description() (string, error)

Description gets a description of the package failure.

func (*FailedPackageReference) Details added in v0.3.0

func (p *FailedPackageReference) Details() ([]string, error)

Details gets the details of the package failure.

func (*FailedPackageReference) LogFilePath added in v0.3.0

func (p *FailedPackageReference) LogFilePath() (string, error)

LogFilePath gets the path to the failed package log file.

func (*FailedPackageReference) ReturnCode added in v0.3.0

func (p *FailedPackageReference) ReturnCode() (string, error)

ReturnCode gets the return code of the failed package.

func (*FailedPackageReference) Signature added in v0.3.0

func (p *FailedPackageReference) Signature() (string, error)

Signature gets a unique signature of the package failure for error reporting.

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance contains information about a Visual Studio 2017 or newer product.

func InstanceForCurrentProcess

func InstanceForCurrentProcess() (*Instance, error)

InstanceForCurrentProcess returns an *Instance for the current process or nil if none found.

func InstanceForPath

func InstanceForPath(path string) (*Instance, error)

InstanceForPath returns an *Instance for the given path or nil if none found.

func Instances

func Instances(all bool) ([]*Instance, error)

Instances returns an array of Instance for Visual Studio 2017 and newer products. Set parameter all to true to enumerate all instances whether launchable or not.

func (*Instance) CatalogInfo added in v0.4.0

func (i *Instance) CatalogInfo() (map[string]interface{}, error)

CatalogInfo gets catalog properties for the instance.

func (*Instance) Close

func (i *Instance) Close() error

Close releases any resources used by this Instance immediately.

func (*Instance) Description

func (i *Instance) Description(locale language.Tag) (string, error)

Description gets the localized description of the Instance. or English if the name is not localized for the given locale.

func (*Instance) DisplayName

func (i *Instance) DisplayName(locale language.Tag) (string, error)

DisplayName gets the localized name of the Instance, or English if the name is not localized for the given locale.

func (*Instance) EnginePath added in v0.2.0

func (i *Instance) EnginePath() (string, error)

EnginePath gets the path to the setup engine that installed this instance.

func (*Instance) ErrorState added in v0.3.0

func (i *Instance) ErrorState() (*ErrorState, error)

ErrorState gets information about failed and skipped packages, as well as log file paths.

func (*Instance) InstallDate

func (i *Instance) InstallDate() (time.Time, error)

InstallDate gets the date the Instance was installed.

func (*Instance) InstallationName

func (i *Instance) InstallationName() (string, error)

InstallationName gets the family name and version of the Instance.

func (*Instance) InstallationPath

func (i *Instance) InstallationPath() (string, error)

InstallationPath gets the root path where the Instance was installed.

func (*Instance) InstanceID

func (i *Instance) InstanceID() (string, error)

InstanceID gets the unique, machine-specific ID for the Instance.

func (*Instance) IsComplete added in v0.2.0

func (i *Instance) IsComplete() (bool, error)

IsComplete gets whether the instance has been completely installed.

func (*Instance) IsLaunchable added in v0.2.0

func (i *Instance) IsLaunchable() (bool, error)

IsLaunchable gets whether the instance can be launched.

func (*Instance) IsPrerelease added in v0.4.0

func (i *Instance) IsPrerelease() (bool, error)

IsPrerelease gets whether the instance is a prerelease version.

func (*Instance) IsRebootRequired added in v0.2.0

func (i *Instance) IsRebootRequired() (bool, error)

IsRebootRequired gets whether the instance requires a reboot before launching.

func (*Instance) MakePath

func (i *Instance) MakePath(path string) (string, error)

MakePath returns the combined Instance installation path with the given child path.

func (*Instance) Packages added in v0.3.0

func (i *Instance) Packages() ([]*PackageReference, error)

func (*Instance) Product added in v0.2.0

func (i *Instance) Product() (*ProductReference, error)

Product gets a reference to the root product package.

func (*Instance) ProductPath added in v0.2.0

func (i *Instance) ProductPath() (string, error)

ProductPath gets the full path to the main executable, if defined.

func (*Instance) Properties added in v0.2.0

func (i *Instance) Properties() (map[string]interface{}, error)

Properties gets a map of property names and values attached to the instance.

func (*Instance) State added in v0.2.0

func (i *Instance) State() (InstanceState, error)

State describes if the instance is complete or other combinations of InstanceState.

type InstanceState added in v0.2.0

type InstanceState uint32
const (
	None             InstanceState = 0
	Local            InstanceState = 1
	Registered       InstanceState = 2
	NoRebootRequired InstanceState = 4
	NoErrors         InstanceState = 8
	Complete         InstanceState = 4294967295
)

type PackageReference added in v0.2.0

type PackageReference struct {
	// contains filtered or unexported fields
}

PackageReference describes unique attributes of a package.

func (*PackageReference) Branch added in v0.2.0

func (p *PackageReference) Branch() (string, error)

Branch gets the package reference branch.

func (*PackageReference) Chip added in v0.2.0

func (p *PackageReference) Chip() (string, error)

Chip gets the package reference chip.

func (*PackageReference) Close added in v0.2.0

func (p *PackageReference) Close() error

Close releases any resources used by this PackageReference immediately.

func (*PackageReference) ID added in v0.2.0

func (p *PackageReference) ID() (string, error)

ID gets the package reference ID.

func (*PackageReference) IsExtension added in v0.2.0

func (p *PackageReference) IsExtension() (bool, error)

IsExtension gets whether the package reference refers to an extension package.

func (*PackageReference) Language added in v0.2.0

func (p *PackageReference) Language() (string, error)

Language gets the package reference language.

func (*PackageReference) Type added in v0.2.0

func (p *PackageReference) Type() (string, error)

Type gets the package reference type.

func (*PackageReference) UniqueID added in v0.2.0

func (p *PackageReference) UniqueID() (string, error)

UniqueID gets a unique, formatted ID for the package reference.

func (*PackageReference) Version added in v0.2.0

func (p *PackageReference) Version() (string, error)

Version gets the package reference version.

type ProductReference added in v0.4.0

type ProductReference struct {
	PackageReference
	// contains filtered or unexported fields
}

ProductReference describes unique attributes of a product package.

func (*ProductReference) Close added in v0.4.0

func (p *ProductReference) Close() error

Close releases any resources used by this ProductReference immediately.

func (*ProductReference) IsInstalled added in v0.4.0

func (p *ProductReference) IsInstalled() (bool, error)

IsInstalled gets whether the product is completely installed.

func (*ProductReference) SupportsExtensions added in v0.4.0

func (p *ProductReference) SupportsExtensions() (bool, error)

SupportsExtensions gets whether the product supports custom extensions e.g., VSIX packages.

type PropertyStore added in v0.4.0

type PropertyStore interface {
	// contains filtered or unexported methods
}

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL