Documentation
¶
Overview ¶
Package msi contains helper functions to work with msi packages.
The package provides automatic retry functionality for MSI operations using exponential backoff to handle transient errors, particularly exit code 1618 (ERROR_INSTALL_ALREADY_RUNNING) which occurs when another MSI installation is in progress.
Package msi contains helper functions to work with msi packages
Index ¶
- func IsProductInstalled(productName string) bool
- func RemoveProduct(ctx context.Context, productName string, opts ...MsiexecOption) error
- type Msiexec
- type MsiexecError
- type MsiexecOption
- func AdministrativeInstall() MsiexecOption
- func HideControlPanelEntry() MsiexecOption
- func Install() MsiexecOption
- func Uninstall() MsiexecOption
- func WithAdditionalArgs(additionalArgs []string) MsiexecOption
- func WithDdAgentUserName(ddagentUserName string) MsiexecOption
- func WithDdAgentUserPassword(ddagentUserPassword string) MsiexecOption
- func WithLogFile(logFile string) MsiexecOption
- func WithMsi(target string) MsiexecOption
- func WithMsiFromPackagePath(target, product string) MsiexecOption
- func WithProduct(productName string) MsiexecOption
- func WithProperties(props map[string]string) MsiexecOption
- type Product
- type TextRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsProductInstalled ¶
IsProductInstalled returns true if the given productName is installed
func RemoveProduct ¶
func RemoveProduct(ctx context.Context, productName string, opts ...MsiexecOption) error
RemoveProduct uses the registry to try and find a product and use msiexec to remove it. It is different from msiexec in that it uses the registry and not the stable/experiment path on disk to uninstall the product. This is needed because in certain circumstances the installer database stored in the stable/experiment paths does not reflect the installed version, and using those installers can lead to undefined behavior (either failure to uninstall, or weird bugs from uninstalling a product with an installer from a different version).
Types ¶
type Msiexec ¶
type Msiexec struct {
// contains filtered or unexported fields
}
Msiexec is a type wrapping msiexec
func Cmd ¶
func Cmd(options ...MsiexecOption) (*Msiexec, error)
Cmd creates a new Msiexec wrapper around cmd.Exec that will call msiexec
type MsiexecError ¶ added in v0.70.0
type MsiexecError struct {
// LogFileBytes contains the processed log file content with error-relevant information
// see openAndProcessLogFile for more details
ProcessedLog string
// contains filtered or unexported fields
}
MsiexecError provides the processed log file content and the underlying error.
func (*MsiexecError) Error ¶ added in v0.70.0
func (e *MsiexecError) Error() string
func (*MsiexecError) Unwrap ¶ added in v0.70.0
func (e *MsiexecError) Unwrap() error
type MsiexecOption ¶
type MsiexecOption func(*msiexecArgs) error
MsiexecOption is an option type for creating msiexec command lines
func AdministrativeInstall ¶
func AdministrativeInstall() MsiexecOption
AdministrativeInstall specifies that msiexec will be invoked to extract the product
func HideControlPanelEntry ¶
func HideControlPanelEntry() MsiexecOption
HideControlPanelEntry passes a flag to msiexec so that the installed program does not show in the Control Panel "Add/Remove Software"
func Install ¶
func Install() MsiexecOption
Install specifies that msiexec will be invoked to install a product
func Uninstall ¶
func Uninstall() MsiexecOption
Uninstall specifies that msiexec will be invoked to uninstall a product
func WithAdditionalArgs ¶
func WithAdditionalArgs(additionalArgs []string) MsiexecOption
WithAdditionalArgs specifies raw additional arguments for msiexec, e.g. []string{"PROP=VALUE", "WIXUI_DONTVALIDATEPATH=1"} These are appended as-is without additional quoting. Use WithProperties for MSI properties to ensure they are properly quoted.
func WithDdAgentUserName ¶
func WithDdAgentUserName(ddagentUserName string) MsiexecOption
WithDdAgentUserName specifies the DDAGENTUSER_NAME to use
func WithDdAgentUserPassword ¶ added in v0.66.0
func WithDdAgentUserPassword(ddagentUserPassword string) MsiexecOption
WithDdAgentUserPassword specifies the DDAGENTUSER_PASSWORD to use
func WithLogFile ¶
func WithLogFile(logFile string) MsiexecOption
WithLogFile specifies the log file for msiexec
func WithMsi ¶
func WithMsi(target string) MsiexecOption
WithMsi specifies the MSI target for msiexec
func WithMsiFromPackagePath ¶
func WithMsiFromPackagePath(target, product string) MsiexecOption
WithMsiFromPackagePath finds an MSI from the packages folder
func WithProduct ¶
func WithProduct(productName string) MsiexecOption
WithProduct specifies the product name to target for msiexec
func WithProperties ¶ added in v0.70.0
func WithProperties(props map[string]string) MsiexecOption
WithProperties specifies additional MSI properties as Key=Value entries. In the final command line, values are always quoted and any embedded quotes are escaped by doubling them. Properties are appended in sorted key order to ensure deterministic command line construction.
type Product ¶
type Product struct {
// Code is the software product code
Code string
// UninstallString is the string that can be executed to uninstall the software. May be empty.
UninstallString string
}
Product represents a software from the Windows Registry
func FindProductCode ¶
FindProductCode looks for the productName in the registry and returns information about it
type TextRange ¶
type TextRange struct {
// contains filtered or unexported fields
}
TextRange is a simple struct to represent a range of text in a file.
func Combine ¶
Combine processes input using multiple logFileProcessors and merges their output ranges.
func FindAllIndexWithContext ¶
func FindAllIndexWithContext(r *regexp.Regexp, input []byte, contextBefore, contextAfter int) []TextRange
FindAllIndexWithContext is similar to FindAllIndex but expands the matched range for a number of lines before and after the TextRange (called contextBefore and contextAfter).