Skip to content

Commit

Permalink
Add support for msix installers (#123)
Browse files Browse the repository at this point in the history
Add support for msixbundles and apps. Install for all users using Add/Remove-AppxProvisisionedPackage.
  • Loading branch information
sbrito85 authored Sep 24, 2024
1 parent bf33c67 commit e08522f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions system/system_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ func Install(dir string, ps *goolib.PkgSpec) error {
err = goolib.Run(exec.Command("wusa", args...), ec, out)
case ".exe":
err = goolib.Run(exec.Command(s, in.Args...), ec, out)
case ".msix", ".msixbundle":
// Add-AppxProvisionedPackage will install for all users.
installCmd := fmt.Sprintf("Add-AppxProvisionedPackage -online -PackagePath %v -SkipLicense", s)
args := append([]string{installCmd}, in.Args...)
err = goolib.Run(exec.Command("powershell", args...), ec, out)
default:
err = goolib.Exec(s, in.Args, in.ExitCodes, out)
}
Expand Down Expand Up @@ -185,6 +190,9 @@ func Uninstall(dir string, ps *goolib.PkgSpec) error {
un.Args = commands[1:]
un.Args = append([]string{"/qn", "/norestart"}, un.Args...)
filePath = un.Path
case ".msix", ".msixbundle":
un.Path = ps.Install.Path
filePath = un.Path
default:
r := regexp.MustCompile(`[^\s"]+|"([^"]*)"`)
u := uninstallString(ps.Name, "")
Expand Down Expand Up @@ -231,6 +239,11 @@ func Uninstall(dir string, ps *goolib.PkgSpec) error {
err = goolib.Run(exec.Command("wusa", args...), ec, out)
case ".exe":
err = goolib.Run(exec.Command(filePath, un.Args...), ec, out)
case ".msix", ".msixbundle":
s := strings.Split(filepath.Base(filePath), "_")[0]
removeCmd := fmt.Sprintf(`Get-AppxProvisionedPackage -online | Where {$_.DisplayName -match "%v*"} | Remove-AppProvisionedPackage -online -AllUsers`, s)
args := append([]string{removeCmd}, un.Args...)
err = goolib.Run(exec.Command("powershell", args...), ec, out)
default:
err = goolib.Exec(filepath.Join(dir, un.Path), un.Args, un.ExitCodes, out)
}
Expand Down

0 comments on commit e08522f

Please sign in to comment.