Skip to content

Commit e08522f

Browse files
authored
Add support for msix installers (#123)
Add support for msixbundles and apps. Install for all users using Add/Remove-AppxProvisisionedPackage.
1 parent bf33c67 commit e08522f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

system/system_windows.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ func Install(dir string, ps *goolib.PkgSpec) error {
156156
err = goolib.Run(exec.Command("wusa", args...), ec, out)
157157
case ".exe":
158158
err = goolib.Run(exec.Command(s, in.Args...), ec, out)
159+
case ".msix", ".msixbundle":
160+
// Add-AppxProvisionedPackage will install for all users.
161+
installCmd := fmt.Sprintf("Add-AppxProvisionedPackage -online -PackagePath %v -SkipLicense", s)
162+
args := append([]string{installCmd}, in.Args...)
163+
err = goolib.Run(exec.Command("powershell", args...), ec, out)
159164
default:
160165
err = goolib.Exec(s, in.Args, in.ExitCodes, out)
161166
}
@@ -185,6 +190,9 @@ func Uninstall(dir string, ps *goolib.PkgSpec) error {
185190
un.Args = commands[1:]
186191
un.Args = append([]string{"/qn", "/norestart"}, un.Args...)
187192
filePath = un.Path
193+
case ".msix", ".msixbundle":
194+
un.Path = ps.Install.Path
195+
filePath = un.Path
188196
default:
189197
r := regexp.MustCompile(`[^\s"]+|"([^"]*)"`)
190198
u := uninstallString(ps.Name, "")
@@ -231,6 +239,11 @@ func Uninstall(dir string, ps *goolib.PkgSpec) error {
231239
err = goolib.Run(exec.Command("wusa", args...), ec, out)
232240
case ".exe":
233241
err = goolib.Run(exec.Command(filePath, un.Args...), ec, out)
242+
case ".msix", ".msixbundle":
243+
s := strings.Split(filepath.Base(filePath), "_")[0]
244+
removeCmd := fmt.Sprintf(`Get-AppxProvisionedPackage -online | Where {$_.DisplayName -match "%v*"} | Remove-AppProvisionedPackage -online -AllUsers`, s)
245+
args := append([]string{removeCmd}, un.Args...)
246+
err = goolib.Run(exec.Command("powershell", args...), ec, out)
234247
default:
235248
err = goolib.Exec(filepath.Join(dir, un.Path), un.Args, un.ExitCodes, out)
236249
}

0 commit comments

Comments
 (0)