From 03f69083ea268812c640499d53bb5de02f93aecd Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Fri, 1 Dec 2023 14:43:25 -0800 Subject: [PATCH 01/12] Windows Package Manager Repair functionality Design spec This commit introduces the initial design specification for the repair functionality in Windows Package Manager. This new feature will allow users to repair installed packages using the Windows Package Manager. --- doc/specs/#148 - Repair Support.md | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 doc/specs/#148 - Repair Support.md diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md new file mode 100644 index 0000000000..ad920aa6f7 --- /dev/null +++ b/doc/specs/#148 - Repair Support.md @@ -0,0 +1,77 @@ +--- +author: Madhusudhan Gumablapura Sudarshan @Madhusudhan-MSFT +created on: 2023-12-01 +last updated: 2023-12-01 +issue id: 148 +--- + +# Repair Feature for Windows Package Manager + +"For [#148](https://github.com/microsoft/winget-cli/issues/148)" + +## Abstract + +This specification outlines the design the design and implementation of a repair feature for the Windows Package Manager.The repair feature aims to provide a convenient and reliable way for users to fix any issues that may arise with their installed applications, such as corrupted files, missing dependencies, or broken registry entries.The initial implementation will support repair for main installer types, such as Msi, Wix, Msix and MSStore installer types, which have native repair capabilities from their respective frameworks. Additionally, other installer types such as Burn/Exe that can specify a custom repair switch in their YAML manifest files can also use the repair feature.The document also outlines the future plans for extending the repair feature to other installer types (Nullsoft, Inno, Portables) that do not have a standard repair mechanism. + +## Inspiration + +The motivation for creating a repair feature in the Windows Package Manager is to provide users with a convenient and consistent way to fix their malfunctioning applications, regardless of the installer type. Currently, users have to rely on different methods to repair their applications, such as using the Windows Settings app, the Control Panel, the command line, or the application's own repair tool. These methods are not always available, accessible, or intuitive, and they may vary depending on the application and the installer type. The repair feature aims to provide a unified experience for users to repair their applications, regardless of the installer type. + +## Solution Design + +### Repair Command Syntax +`winget repair ` +will initiate the repair of the application whose name matches the search results.The command will display an error message if the application is not installed. The command will attempt to repair the application if it is installed. The command will display a success message if the repair succeeds. The command will display an error message if the repair fails. + +### Repair Feature for different Installer Types with Native Repair Capabilities + - Msi, Wix : The repair command will use the built-in repair features of the MSI installer type. It will run the msiexec command with the default [repair options](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#repair-options) to repair the application using a ShellExecute call or by invoking [MsiReinstallProduct](https://learn.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallproductw) API call with REINSTALLMODE mode property set. + - Msix : The repair command will use the built-in repair features of the MSIX installer type. It will make an MSIX API call to register the application package, which will usually fix the application as much as possible. + > We can't do the same thing as setting app repair for MSIX app right now because we can't use the private APIs that it uses to do repair operations with winget. + - MSStore : The repair command will make an MSStore API [StartProductInstallAsync](https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.store.preview.installcontrol.appinstallmanager.startproductinstallasync?view=winrt-22621) call to repair the application with 'Repair' property of AppInstallOption set to true. + +### Repair Feature for Installer Types that require Custom Repair Switch + - Burn/Exe : The custom switch for repair in the YAML manifest file will be used to perform the repair. The repair command will run the installer with the custom switch to fix the application. To have enough flexibility, different options are possible depending on the installer source used for repair. + - Installed Source: If the YAML manifest file has the 'ModifyRepair' switch, the repair command will use the modify command in the ARP 'ModifyPath' registry key with the repair switch through a ShellExecute call. + - Remote Source: If the YAML manifest file has the 'InstalleRepair' switch, the repair command will get the matching installer from the remote source and use the repair switch on the downloaded installer through a ShellExecute call. + > If neither switch is specified, the repair command will display an error message. + +> Note: The initial implementation will not support repair for Nullsoft, Inno, Portables installer types. Based on feedback from the community, we may add the repair feature for these installer types in a future release. + +## Manifest Changes +Addition of `ModifyRepair` property to InstallerSwitch +- The `ModifyRepair` property is used to define the custom repair option that works with ModifyPath ARP entry for those installer types that have ModifyPath ARP entry and allow repair through Modify flow. + +Addition of `InstallerRepair` property to InstallerSwitch +- With the `InstallerRepair` switch, the installer that matches the remote source is downloaded and then repaired by using ShellExecute to call the repair switch on the downloaded installer. + +## Manifest Validation +- `ModifyRepair` and `InstallerRepair` switches are only valid for Burn/Exe installer types. +- `ModifyRepair` and `InstallerRepair` switches are mutually exclusive. + +## Supported Repair Scenarios +- Repair for installed applications of Msi, Wix, Msix and MSStore installer types. +- Repair for the application using the custom repair switch specified in the YAML manifest file for Burn/Exe installer types. + - The ‘ModifyRepair’ switch when using the ModifyPath ARP entry for repair. + - The `InstallerRepair' switch when using the remote installer source for repair. + +## Potential Issues +- Repair for Nullsoft, Inno, Portables installer types are not supported in the initial implementation. +- For Burn/Exe installer types + - the repair command will not work if the installer does not have a custom repair switch specified in the YAML manifest file. + - the repair command will not work if the installed Burn/Exe installer type doesn't correlated to the remote installer type that has a custom repair switch specified in the YAML manifest file. + +## Future considerations + +- Repair for Nullsoft, Inno, Portables installer types. The possible options are: + - Download matching installer , uninstall & Install or + - Download matching installer & re Install to overwrite existing files. +- Repair for Burn/Exe installer types without custom repair switch. The possible options are: + - Download matching installer , uninstall & Install or + - Download matching installer & re Install to overwrite existing files. + +## Resources +- https://learn.microsoft.com/en-us/windows/msix/desktop/managing-your-msix-reset-and-repair +- https://learn.microsoft.com/en-us/windows/win32/msi/reinstalling-a-feature-or-application +- https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#repair-options +- https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.store.preview.installcontrol.appinstallmanager.startproductinstallasync?view=winrt-22621 +- https://learn.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallproductw From ed0f9adb532c119e33bb90e29d253f1947979b6c Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Fri, 1 Dec 2023 15:15:20 -0800 Subject: [PATCH 02/12] Resolve spelling-bot report issues --- doc/specs/#148 - Repair Support.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md index ad920aa6f7..32bed4b0bd 100644 --- a/doc/specs/#148 - Repair Support.md +++ b/doc/specs/#148 - Repair Support.md @@ -1,5 +1,5 @@ --- -author: Madhusudhan Gumablapura Sudarshan @Madhusudhan-MSFT +author: Madhusudhan Gumbalapura Sudarshan @Madhusudhan-MSFT created on: 2023-12-01 last updated: 2023-12-01 issue id: 148 @@ -24,7 +24,7 @@ The motivation for creating a repair feature in the Windows Package Manager is t will initiate the repair of the application whose name matches the search results.The command will display an error message if the application is not installed. The command will attempt to repair the application if it is installed. The command will display a success message if the repair succeeds. The command will display an error message if the repair fails. ### Repair Feature for different Installer Types with Native Repair Capabilities - - Msi, Wix : The repair command will use the built-in repair features of the MSI installer type. It will run the msiexec command with the default [repair options](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#repair-options) to repair the application using a ShellExecute call or by invoking [MsiReinstallProduct](https://learn.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallproductw) API call with REINSTALLMODE mode property set. + - Msi, Wix : The repair command will use the built-in repair features of the MSI installer type. It will run the msiexec command with the default [repair options](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#repair-options) to repair the application using a ShellExecute call or by invoking [MsiReinstallProduct](https://learn.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallproductw) API call with `REINSTALLMODE` mode property set. - Msix : The repair command will use the built-in repair features of the MSIX installer type. It will make an MSIX API call to register the application package, which will usually fix the application as much as possible. > We can't do the same thing as setting app repair for MSIX app right now because we can't use the private APIs that it uses to do repair operations with winget. - MSStore : The repair command will make an MSStore API [StartProductInstallAsync](https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.store.preview.installcontrol.appinstallmanager.startproductinstallasync?view=winrt-22621) call to repair the application with 'Repair' property of AppInstallOption set to true. @@ -32,7 +32,7 @@ will initiate the repair of the application whose name matches the search result ### Repair Feature for Installer Types that require Custom Repair Switch - Burn/Exe : The custom switch for repair in the YAML manifest file will be used to perform the repair. The repair command will run the installer with the custom switch to fix the application. To have enough flexibility, different options are possible depending on the installer source used for repair. - Installed Source: If the YAML manifest file has the 'ModifyRepair' switch, the repair command will use the modify command in the ARP 'ModifyPath' registry key with the repair switch through a ShellExecute call. - - Remote Source: If the YAML manifest file has the 'InstalleRepair' switch, the repair command will get the matching installer from the remote source and use the repair switch on the downloaded installer through a ShellExecute call. + - Remote Source: If the YAML manifest file has the 'InstallerRepair' switch, the repair command will get the matching installer from the remote source and use the repair switch on the downloaded installer through a ShellExecute call. > If neither switch is specified, the repair command will display an error message. > Note: The initial implementation will not support repair for Nullsoft, Inno, Portables installer types. Based on feedback from the community, we may add the repair feature for these installer types in a future release. From af3daf95b9c530e364ea721d1ce3e4d3b0fdfe5b Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Fri, 1 Dec 2023 15:32:37 -0800 Subject: [PATCH 03/12] Update spelling-bot expected entries This commit fixes the spelling-bot report by adding the expected entries to the expect.txt file. --- .github/actions/spelling/expect.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 3e46e03d6d..f396050a75 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -187,6 +187,7 @@ Gomu GRPICONDIR GRPICONDIRENTRY guiddef +Gumbalapura Hackathon hashtables helplib @@ -284,6 +285,7 @@ LTDA luffy Luffytaro maclachlan +Madhusudhan MAJORVERSION malware mapdatafolding @@ -434,6 +436,7 @@ REFIID REGDB regexes REGSAM +REINSTALLMODE relativefilepath remoting removefile @@ -510,6 +513,7 @@ STRRET stylecop subdir subkey +Sudarshan superstring swervy SYD From e6186e58b17b1601b2b848610e7f71bd1fbfb74f Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Fri, 1 Dec 2023 15:55:55 -0800 Subject: [PATCH 04/12] Incorporate PR feedback from Demetrius --- doc/specs/#148 - Repair Support.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md index 32bed4b0bd..1de157ef99 100644 --- a/doc/specs/#148 - Repair Support.md +++ b/doc/specs/#148 - Repair Support.md @@ -11,7 +11,7 @@ issue id: 148 ## Abstract -This specification outlines the design the design and implementation of a repair feature for the Windows Package Manager.The repair feature aims to provide a convenient and reliable way for users to fix any issues that may arise with their installed applications, such as corrupted files, missing dependencies, or broken registry entries.The initial implementation will support repair for main installer types, such as Msi, Wix, Msix and MSStore installer types, which have native repair capabilities from their respective frameworks. Additionally, other installer types such as Burn/Exe that can specify a custom repair switch in their YAML manifest files can also use the repair feature.The document also outlines the future plans for extending the repair feature to other installer types (Nullsoft, Inno, Portables) that do not have a standard repair mechanism. +This specification outlines the design and implementation of a repair feature for the Windows Package Manager.The repair feature aims to provide a convenient and reliable way for users to fix any issues that may arise with their installed applications, such as corrupted files, missing dependencies, or broken registry entries.The initial implementation will support repair for main installer types, such as Msi, Wix, Msix and MSStore installer types, which have native repair capabilities from their respective frameworks. Additionally, other installer types such as Burn/Exe that can specify a custom repair switch in their YAML manifest files can also use the repair feature.The document also outlines the future plans for extending the repair feature to other installer types (Nullsoft, Inno, Portables) that do not have a standard repair mechanism. ## Inspiration @@ -20,12 +20,12 @@ The motivation for creating a repair feature in the Windows Package Manager is t ## Solution Design ### Repair Command Syntax -`winget repair ` -will initiate the repair of the application whose name matches the search results.The command will display an error message if the application is not installed. The command will attempt to repair the application if it is installed. The command will display a success message if the repair succeeds. The command will display an error message if the repair fails. +`winget repair ` +will initiate the repair of the specified package. The command will display an error message if the application is not installed. The command will attempt to repair the application if it is installed. The command will display a success message if the repair succeeds. The command will display an error message if the repair fails. ### Repair Feature for different Installer Types with Native Repair Capabilities - Msi, Wix : The repair command will use the built-in repair features of the MSI installer type. It will run the msiexec command with the default [repair options](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#repair-options) to repair the application using a ShellExecute call or by invoking [MsiReinstallProduct](https://learn.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallproductw) API call with `REINSTALLMODE` mode property set. - - Msix : The repair command will use the built-in repair features of the MSIX installer type. It will make an MSIX API call to register the application package, which will usually fix the application as much as possible. + - Msix : The repair command will use the built-in repair features of the MSIX installer type. It will make an MSIX API call to register the application package, which will attempt to repair the package. > We can't do the same thing as setting app repair for MSIX app right now because we can't use the private APIs that it uses to do repair operations with winget. - MSStore : The repair command will make an MSStore API [StartProductInstallAsync](https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.store.preview.installcontrol.appinstallmanager.startproductinstallasync?view=winrt-22621) call to repair the application with 'Repair' property of AppInstallOption set to true. From 0d980b14e81d760ed9acb4704021be2d70de17e5 Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Mon, 4 Dec 2023 16:02:55 -0800 Subject: [PATCH 05/12] Revise Potential Issues section to only include immediate implementation scope --- doc/specs/#148 - Repair Support.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md index 1de157ef99..2f1b76537c 100644 --- a/doc/specs/#148 - Repair Support.md +++ b/doc/specs/#148 - Repair Support.md @@ -55,7 +55,6 @@ Addition of `InstallerRepair` property to InstallerSwitch - The `InstallerRepair' switch when using the remote installer source for repair. ## Potential Issues -- Repair for Nullsoft, Inno, Portables installer types are not supported in the initial implementation. - For Burn/Exe installer types - the repair command will not work if the installer does not have a custom repair switch specified in the YAML manifest file. - the repair command will not work if the installed Burn/Exe installer type doesn't correlated to the remote installer type that has a custom repair switch specified in the YAML manifest file. From e77f1c2882bbf7be2e67175e47dced9ea6993190 Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Mon, 4 Dec 2023 16:31:16 -0800 Subject: [PATCH 06/12] =?UTF-8?q?Consider=20custom=20repair=20switch=20sup?= =?UTF-8?q?port=20for=20Msi/Wix=20installer=C2=92s=20ModifyRepair=20and=20?= =?UTF-8?q?InstallerRepair=20in=20future=20scope?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/specs/#148 - Repair Support.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md index 2f1b76537c..4e89927b2e 100644 --- a/doc/specs/#148 - Repair Support.md +++ b/doc/specs/#148 - Repair Support.md @@ -45,7 +45,7 @@ Addition of `InstallerRepair` property to InstallerSwitch - With the `InstallerRepair` switch, the installer that matches the remote source is downloaded and then repaired by using ShellExecute to call the repair switch on the downloaded installer. ## Manifest Validation -- `ModifyRepair` and `InstallerRepair` switches are only valid for Burn/Exe installer types. +- `ModifyRepair` and `InstallerRepair` switches are only valid for Burn/Exe and Msi/WiX installer types. - `ModifyRepair` and `InstallerRepair` switches are mutually exclusive. ## Supported Repair Scenarios @@ -67,6 +67,7 @@ Addition of `InstallerRepair` property to InstallerSwitch - Repair for Burn/Exe installer types without custom repair switch. The possible options are: - Download matching installer , uninstall & Install or - Download matching installer & re Install to overwrite existing files. +- Repair for Msi/WiX installer type with custom repair switch. ## Resources - https://learn.microsoft.com/en-us/windows/msix/desktop/managing-your-msix-reset-and-repair From 56b0f47ca4e62b1710a341f922111a31c086d9e7 Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Mon, 4 Dec 2023 16:46:58 -0800 Subject: [PATCH 07/12] Fix incorrect markdown formatting in Supported repair scenarios. --- doc/specs/#148 - Repair Support.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md index 4e89927b2e..7677108cbf 100644 --- a/doc/specs/#148 - Repair Support.md +++ b/doc/specs/#148 - Repair Support.md @@ -51,8 +51,8 @@ Addition of `InstallerRepair` property to InstallerSwitch ## Supported Repair Scenarios - Repair for installed applications of Msi, Wix, Msix and MSStore installer types. - Repair for the application using the custom repair switch specified in the YAML manifest file for Burn/Exe installer types. - - The ‘ModifyRepair’ switch when using the ModifyPath ARP entry for repair. - - The `InstallerRepair' switch when using the remote installer source for repair. + - The `ModifyRepair` switch when using the ModifyPath ARP entry for repair. + - The `InstallerRepair` switch when using the remote installer source for repair. ## Potential Issues - For Burn/Exe installer types From 9731d2e3c93665a7d6b3885e7213d014f843fd48 Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Fri, 8 Dec 2023 16:10:51 -0800 Subject: [PATCH 08/12] Dev spec revised according to latest feedback --- doc/specs/#148 - Repair Support.md | 56 ++++++++++++++++++------------ 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md index 7677108cbf..8761b9078b 100644 --- a/doc/specs/#148 - Repair Support.md +++ b/doc/specs/#148 - Repair Support.md @@ -11,7 +11,7 @@ issue id: 148 ## Abstract -This specification outlines the design and implementation of a repair feature for the Windows Package Manager.The repair feature aims to provide a convenient and reliable way for users to fix any issues that may arise with their installed applications, such as corrupted files, missing dependencies, or broken registry entries.The initial implementation will support repair for main installer types, such as Msi, Wix, Msix and MSStore installer types, which have native repair capabilities from their respective frameworks. Additionally, other installer types such as Burn/Exe that can specify a custom repair switch in their YAML manifest files can also use the repair feature.The document also outlines the future plans for extending the repair feature to other installer types (Nullsoft, Inno, Portables) that do not have a standard repair mechanism. +This specification outlines the design and implementation of a repair feature for the Windows Package Manager.The repair feature aims to provide a convenient and reliable way for users to fix any issues that may arise with their installed applications, such as corrupted files, missing dependencies, or broken registry entries.The initial implementation will support repair for main installer types, such as Msi, Wix, Msix and MSStore installer types, which have native repair capabilities from their respective frameworks. Additionally, other installer types such as Burn/Exe/Nullsoft/Inno that can specify a custom repair switch in their YAML manifest files can also use the repair feature.The document also outlines the future plans for extending the repair feature to other installer types Portables that do not have a standard repair mechanism. ## Inspiration @@ -30,44 +30,54 @@ will initiate the repair of the specified package. The command will display an e - MSStore : The repair command will make an MSStore API [StartProductInstallAsync](https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.store.preview.installcontrol.appinstallmanager.startproductinstallasync?view=winrt-22621) call to repair the application with 'Repair' property of AppInstallOption set to true. ### Repair Feature for Installer Types that require Custom Repair Switch - - Burn/Exe : The custom switch for repair in the YAML manifest file will be used to perform the repair. The repair command will run the installer with the custom switch to fix the application. To have enough flexibility, different options are possible depending on the installer source used for repair. - - Installed Source: If the YAML manifest file has the 'ModifyRepair' switch, the repair command will use the modify command in the ARP 'ModifyPath' registry key with the repair switch through a ShellExecute call. - - Remote Source: If the YAML manifest file has the 'InstallerRepair' switch, the repair command will get the matching installer from the remote source and use the repair switch on the downloaded installer through a ShellExecute call. - > If neither switch is specified, the repair command will display an error message. + - Burn, Exe, Nullsoft & Inno : The custom switch for repair in the YAML manifest file will be used to perform the repair. The repair command will run the installer with the custom switch to repair the application. To have enough flexibility, different options are possible depending on the installer source used for repair. + - Installed Source: + - If the YAML manifest file specifies the `Repair` switch and `Modify` as the `RepairType`, the repair command will use the modify command in the ARP `ModifyPath` registry key, along with the repair switch, through a ShellExecute call, as long as `NoModify` and `NoRepair` ARP registry flags are not set to 1. + - If the YAML manifest file specifies the `Repair` switch and `Uninstaller` as the RepairType, the repair command will use the uninstall command in the ARP `UninstallString` registry key, along with the repair switch, through a ShellExecute call, as long as `NoRepair` APR registry flag is not set to 1. + - Remote Source: If the YAML manifest file specifies the `Repair` switch and `Installer` valure for the RepairType, the repair command will obtain the matching installer from the remote source and use the repair switch on the downloaded installer through a ShellExecute call.. -> Note: The initial implementation will not support repair for Nullsoft, Inno, Portables installer types. Based on feedback from the community, we may add the repair feature for these installer types in a future release. +> If neither switch is specified, the repair command will display an error message. -## Manifest Changes -Addition of `ModifyRepair` property to InstallerSwitch -- The `ModifyRepair` property is used to define the custom repair option that works with ModifyPath ARP entry for those installer types that have ModifyPath ARP entry and allow repair through Modify flow. +> Note: The initial implementation will not support repair for Portables installer type. Based on feedback from the community, we may add the repair feature for these installer type in a future release. -Addition of `InstallerRepair` property to InstallerSwitch -- With the `InstallerRepair` switch, the installer that matches the remote source is downloaded and then repaired by using ShellExecute to call the repair switch on the downloaded installer. +## Manifest Changes +Addition of `Repair` property to InstallerSwitch +- The `Repair` property is used to set the custom repair option that works with `RepairType` field that controls the different repair behavior. + +Addition of `RepairType` enumerable property to InstallerSwitch +- With the `RepairType` switch, we can adjust the repair behavior by choosing the installer source (Installed/local or remote) and making sure that the proper ARP registry entries are applied to identify the local installer type when carrying out a repair operation using a local installer source. +- The permitted initial values for the `RepairType` switch include: + - Performing a repair using a Installed/Local Installer Source: + - `Modify`: if this option is specified, the repair switch will be applied to the `ModifyPath` ARP command entry, as long as `NoModify` and `NoRepair` ARP registry flags are not set to 1. + - `Uninstaller` : if this option is specified, the repair switch will be applied to the `UninstallString` ARP command entry, as long as `NoRepair` APR registry flag is note set to 1. + - Performing a repair using a Remote Installer Source: + - `Installer` : If this option is specified, the repair switch will be applied to the appropriate installer obtained from the remote installer source. ## Manifest Validation -- `ModifyRepair` and `InstallerRepair` switches are only valid for Burn/Exe and Msi/WiX installer types. -- `ModifyRepair` and `InstallerRepair` switches are mutually exclusive. +- Specifying `Repair` switch without `RepairType` switch will result in an error. + - Specifying `RepairType` switch without `Repair` switch will result in an error. + - `Repair` switch can't be empty when specified. + - `RepairType` switch can't be empty when specified. + ## Supported Repair Scenarios - Repair for installed applications of Msi, Wix, Msix and MSStore installer types. -- Repair for the application using the custom repair switch specified in the YAML manifest file for Burn/Exe installer types. - - The `ModifyRepair` switch when using the ModifyPath ARP entry for repair. - - The `InstallerRepair` switch when using the remote installer source for repair. +- Repair for the application using the custom repair switch specified in the YAML manifest file for Burn/Exe/Nullsoft/Inno/Wix/Msi installer types. + - The appropriate repair behavior is determined by the combination of the `Repair` switch and the `RepairType` value in the YAML manifest.. ## Potential Issues -- For Burn/Exe installer types +- For Burn/Exe/Nullsoft/Inno installer types - the repair command will not work if the installer does not have a custom repair switch specified in the YAML manifest file. - - the repair command will not work if the installed Burn/Exe installer type doesn't correlated to the remote installer type that has a custom repair switch specified in the YAML manifest file. + - the repair command will not work if the installed Burn/Exe/Nullsoft/inno installer type doesn't correlate to the remote installer type that has a custom repair switch specified in the YAML manifest file. ## Future considerations -- Repair for Nullsoft, Inno, Portables installer types. The possible options are: - - Download matching installer , uninstall & Install or +- Repair for Portables installer types. The possible options are: + - Download matching installer , uninstall & Install OR - Download matching installer & re Install to overwrite existing files. -- Repair for Burn/Exe installer types without custom repair switch. The possible options are: - - Download matching installer , uninstall & Install or +- Repair for Burn/Exe/Nullsoft/Inno installer types without custom repair switch. The possible options are: + - Download matching installer , uninstall & Install OR - Download matching installer & re Install to overwrite existing files. -- Repair for Msi/WiX installer type with custom repair switch. ## Resources - https://learn.microsoft.com/en-us/windows/msix/desktop/managing-your-msix-reset-and-repair From 7bc31aaddf0a8700597f5f3b30921d642548d540 Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Tue, 12 Dec 2023 14:40:31 -0800 Subject: [PATCH 09/12] Initial list of query/optional arguments added to repair feature. --- doc/specs/#148 - Repair Support.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md index 8761b9078b..bcc0888fb3 100644 --- a/doc/specs/#148 - Repair Support.md +++ b/doc/specs/#148 - Repair Support.md @@ -20,9 +20,35 @@ The motivation for creating a repair feature in the Windows Package Manager is t ## Solution Design ### Repair Command Syntax -`winget repair ` +`winget repair [[-q] ...] []` will initiate the repair of the specified package. The command will display an error message if the application is not installed. The command will attempt to repair the application if it is installed. The command will display a success message if the repair succeeds. The command will display an error message if the repair fails. +#### Arguments +| Argument | Description | +|-------------|-------------| +| **-q,--query** | The query used to search for an app. | + + +#### Optional Arguments + +| Option | Description | +|--------|-------------| +| **-m, --manifest** | Must be followed by the path to the manifest (YAML) file.You can use the manifest to run the repair experience from a [local manifest file](#local-repair).| +| **--id** | Limits the repair to the specified ID of the application.| +| **--name** | Limits the repair to the specified name of the application.| +| **--moniker** | Limits the repair to the specified moniker of the application.| +| **-v --version** | Limits the repair to the specified version of the application.If not specified, the repair will be applied to the latest version of the application.| +| **--architectures** | Select the architecture | +| **-s --source** | Limits the serach to specified source(s).Must be followed by the source name.| +| **-o, --log** | Directs the logging to a log file. You must provide a path to a file that you have the write rights to. | +| **-i --interactive** | Runs the repair in interactive mode.| +| **-h --silent** | Runs the repair in silent mode.| +| **-?, --help** | Get additional help on this command. | +| **--accept-source-agreements** | Accept all source agreements during source operations | +| **--logs, --open-logs** | Open the default logs location. | +| **--locale** | Sets the locale.| + + ### Repair Feature for different Installer Types with Native Repair Capabilities - Msi, Wix : The repair command will use the built-in repair features of the MSI installer type. It will run the msiexec command with the default [repair options](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#repair-options) to repair the application using a ShellExecute call or by invoking [MsiReinstallProduct](https://learn.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallproductw) API call with `REINSTALLMODE` mode property set. - Msix : The repair command will use the built-in repair features of the MSIX installer type. It will make an MSIX API call to register the application package, which will attempt to repair the package. From 042f9d515f2c3cb85553d2767c75bdce21ebc8b4 Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Sun, 17 Dec 2023 20:52:18 -0800 Subject: [PATCH 10/12] Corrected spell check bot errors --- doc/specs/#148 - Repair Support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md index bcc0888fb3..4700d04677 100644 --- a/doc/specs/#148 - Repair Support.md +++ b/doc/specs/#148 - Repair Support.md @@ -39,7 +39,7 @@ will initiate the repair of the specified package. The command will display an e | **--moniker** | Limits the repair to the specified moniker of the application.| | **-v --version** | Limits the repair to the specified version of the application.If not specified, the repair will be applied to the latest version of the application.| | **--architectures** | Select the architecture | -| **-s --source** | Limits the serach to specified source(s).Must be followed by the source name.| +| **-s --source** | Limits the search to specified source(s).Must be followed by the source name.| | **-o, --log** | Directs the logging to a log file. You must provide a path to a file that you have the write rights to. | | **-i --interactive** | Runs the repair in interactive mode.| | **-h --silent** | Runs the repair in silent mode.| From c04357de04c457f5d5b4441f3d5f54d08cab682b Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Mon, 8 Jan 2024 12:14:00 -0800 Subject: [PATCH 11/12] =?UTF-8?q?Update=20design=20document=20and=20YAML?= =?UTF-8?q?=20manifest=20to=20replace=20=C2=91RepairType=C2=92=20with=20?= =?UTF-8?q?=C2=91RepairBehavior=C2=92=20and=20change=20its=20scope=20to=20?= =?UTF-8?q?Installer=20object.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/specs/#148 - Repair Support.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md index 4700d04677..acc1f98bbc 100644 --- a/doc/specs/#148 - Repair Support.md +++ b/doc/specs/#148 - Repair Support.md @@ -58,9 +58,9 @@ will initiate the repair of the specified package. The command will display an e ### Repair Feature for Installer Types that require Custom Repair Switch - Burn, Exe, Nullsoft & Inno : The custom switch for repair in the YAML manifest file will be used to perform the repair. The repair command will run the installer with the custom switch to repair the application. To have enough flexibility, different options are possible depending on the installer source used for repair. - Installed Source: - - If the YAML manifest file specifies the `Repair` switch and `Modify` as the `RepairType`, the repair command will use the modify command in the ARP `ModifyPath` registry key, along with the repair switch, through a ShellExecute call, as long as `NoModify` and `NoRepair` ARP registry flags are not set to 1. - - If the YAML manifest file specifies the `Repair` switch and `Uninstaller` as the RepairType, the repair command will use the uninstall command in the ARP `UninstallString` registry key, along with the repair switch, through a ShellExecute call, as long as `NoRepair` APR registry flag is not set to 1. - - Remote Source: If the YAML manifest file specifies the `Repair` switch and `Installer` valure for the RepairType, the repair command will obtain the matching installer from the remote source and use the repair switch on the downloaded installer through a ShellExecute call.. + - If the YAML manifest file specifies the `Repair` switch and `Modify` as the `RepairBehavior`, the repair command will use the modify command in the ARP `ModifyPath` registry key, along with the repair switch, through a ShellExecute call, as long as `NoModify` and `NoRepair` ARP registry flags are not set to 1. + - If the YAML manifest file specifies the `Repair` switch and `Uninstaller` as the RepairBehavior, the repair command will use the uninstall command in the ARP `UninstallString` registry key, along with the repair switch, through a ShellExecute call, as long as `NoRepair` APR registry flag is not set to 1. + - Remote Source: If the YAML manifest file specifies the `Repair` switch and `Installer` valure for the RepairBehavior, the repair command will obtain the matching installer from the remote source and use the repair switch on the downloaded installer through a ShellExecute call.. > If neither switch is specified, the repair command will display an error message. @@ -68,11 +68,11 @@ will initiate the repair of the specified package. The command will display an e ## Manifest Changes Addition of `Repair` property to InstallerSwitch -- The `Repair` property is used to set the custom repair option that works with `RepairType` field that controls the different repair behavior. +- The `Repair` property is used to set the custom repair option that works with `RepairBehavior` field that controls the different repair behavior. -Addition of `RepairType` enumerable property to InstallerSwitch -- With the `RepairType` switch, we can adjust the repair behavior by choosing the installer source (Installed/local or remote) and making sure that the proper ARP registry entries are applied to identify the local installer type when carrying out a repair operation using a local installer source. -- The permitted initial values for the `RepairType` switch include: +Addition of `RepairBehavior` enumerable property to Installer Object +- With the `RepairBehavior` switch, we can adjust the repair behavior by choosing the installer source (Installed/local or remote) and making sure that the proper ARP registry entries are applied to identify the local installer type when carrying out a repair operation using a local installer source. +- The permitted initial values for the `RepairBehavior` switch include: - Performing a repair using a Installed/Local Installer Source: - `Modify`: if this option is specified, the repair switch will be applied to the `ModifyPath` ARP command entry, as long as `NoModify` and `NoRepair` ARP registry flags are not set to 1. - `Uninstaller` : if this option is specified, the repair switch will be applied to the `UninstallString` ARP command entry, as long as `NoRepair` APR registry flag is note set to 1. @@ -80,16 +80,16 @@ Addition of `RepairType` enumerable property to InstallerSwitch - `Installer` : If this option is specified, the repair switch will be applied to the appropriate installer obtained from the remote installer source. ## Manifest Validation -- Specifying `Repair` switch without `RepairType` switch will result in an error. - - Specifying `RepairType` switch without `Repair` switch will result in an error. +- Specifying `Repair` switch without `RepairBehavior` switch will result in an error. + - Specifying `RepairBehavior` switch without `Repair` switch will result in an error. - `Repair` switch can't be empty when specified. - - `RepairType` switch can't be empty when specified. + - `RepairBehavior` switch can't be empty when specified. ## Supported Repair Scenarios - Repair for installed applications of Msi, Wix, Msix and MSStore installer types. - Repair for the application using the custom repair switch specified in the YAML manifest file for Burn/Exe/Nullsoft/Inno/Wix/Msi installer types. - - The appropriate repair behavior is determined by the combination of the `Repair` switch and the `RepairType` value in the YAML manifest.. + - The appropriate repair behavior is determined by the combination of the `Repair` switch and the `RepairBehavior` value in the YAML manifest. ## Potential Issues - For Burn/Exe/Nullsoft/Inno installer types From 2fb2672e0ba62eeeaae9c373c492c5b8ae5e8ec0 Mon Sep 17 00:00:00 2001 From: Madhusudhan Gumbalapura Sudarshan Date: Tue, 27 Aug 2024 00:21:08 -0700 Subject: [PATCH 12/12] Update Repair Design Documentation - Corrected typos - Included a section on Elevation Requirements - Highlighted potential issues with repairing MSI-based installers using msiexec when the original installer is missing or renamed. --- doc/specs/#148 - Repair Support.md | 233 +++++++++++++++-------------- 1 file changed, 120 insertions(+), 113 deletions(-) diff --git a/doc/specs/#148 - Repair Support.md b/doc/specs/#148 - Repair Support.md index acc1f98bbc..d3556ef1d7 100644 --- a/doc/specs/#148 - Repair Support.md +++ b/doc/specs/#148 - Repair Support.md @@ -1,113 +1,120 @@ ---- -author: Madhusudhan Gumbalapura Sudarshan @Madhusudhan-MSFT -created on: 2023-12-01 -last updated: 2023-12-01 -issue id: 148 ---- - -# Repair Feature for Windows Package Manager - -"For [#148](https://github.com/microsoft/winget-cli/issues/148)" - -## Abstract - -This specification outlines the design and implementation of a repair feature for the Windows Package Manager.The repair feature aims to provide a convenient and reliable way for users to fix any issues that may arise with their installed applications, such as corrupted files, missing dependencies, or broken registry entries.The initial implementation will support repair for main installer types, such as Msi, Wix, Msix and MSStore installer types, which have native repair capabilities from their respective frameworks. Additionally, other installer types such as Burn/Exe/Nullsoft/Inno that can specify a custom repair switch in their YAML manifest files can also use the repair feature.The document also outlines the future plans for extending the repair feature to other installer types Portables that do not have a standard repair mechanism. - -## Inspiration - -The motivation for creating a repair feature in the Windows Package Manager is to provide users with a convenient and consistent way to fix their malfunctioning applications, regardless of the installer type. Currently, users have to rely on different methods to repair their applications, such as using the Windows Settings app, the Control Panel, the command line, or the application's own repair tool. These methods are not always available, accessible, or intuitive, and they may vary depending on the application and the installer type. The repair feature aims to provide a unified experience for users to repair their applications, regardless of the installer type. - -## Solution Design - -### Repair Command Syntax -`winget repair [[-q] ...] []` -will initiate the repair of the specified package. The command will display an error message if the application is not installed. The command will attempt to repair the application if it is installed. The command will display a success message if the repair succeeds. The command will display an error message if the repair fails. - -#### Arguments -| Argument | Description | -|-------------|-------------| -| **-q,--query** | The query used to search for an app. | - - -#### Optional Arguments - -| Option | Description | -|--------|-------------| -| **-m, --manifest** | Must be followed by the path to the manifest (YAML) file.You can use the manifest to run the repair experience from a [local manifest file](#local-repair).| -| **--id** | Limits the repair to the specified ID of the application.| -| **--name** | Limits the repair to the specified name of the application.| -| **--moniker** | Limits the repair to the specified moniker of the application.| -| **-v --version** | Limits the repair to the specified version of the application.If not specified, the repair will be applied to the latest version of the application.| -| **--architectures** | Select the architecture | -| **-s --source** | Limits the search to specified source(s).Must be followed by the source name.| -| **-o, --log** | Directs the logging to a log file. You must provide a path to a file that you have the write rights to. | -| **-i --interactive** | Runs the repair in interactive mode.| -| **-h --silent** | Runs the repair in silent mode.| -| **-?, --help** | Get additional help on this command. | -| **--accept-source-agreements** | Accept all source agreements during source operations | -| **--logs, --open-logs** | Open the default logs location. | -| **--locale** | Sets the locale.| - - -### Repair Feature for different Installer Types with Native Repair Capabilities - - Msi, Wix : The repair command will use the built-in repair features of the MSI installer type. It will run the msiexec command with the default [repair options](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#repair-options) to repair the application using a ShellExecute call or by invoking [MsiReinstallProduct](https://learn.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallproductw) API call with `REINSTALLMODE` mode property set. - - Msix : The repair command will use the built-in repair features of the MSIX installer type. It will make an MSIX API call to register the application package, which will attempt to repair the package. - > We can't do the same thing as setting app repair for MSIX app right now because we can't use the private APIs that it uses to do repair operations with winget. - - MSStore : The repair command will make an MSStore API [StartProductInstallAsync](https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.store.preview.installcontrol.appinstallmanager.startproductinstallasync?view=winrt-22621) call to repair the application with 'Repair' property of AppInstallOption set to true. - -### Repair Feature for Installer Types that require Custom Repair Switch - - Burn, Exe, Nullsoft & Inno : The custom switch for repair in the YAML manifest file will be used to perform the repair. The repair command will run the installer with the custom switch to repair the application. To have enough flexibility, different options are possible depending on the installer source used for repair. - - Installed Source: - - If the YAML manifest file specifies the `Repair` switch and `Modify` as the `RepairBehavior`, the repair command will use the modify command in the ARP `ModifyPath` registry key, along with the repair switch, through a ShellExecute call, as long as `NoModify` and `NoRepair` ARP registry flags are not set to 1. - - If the YAML manifest file specifies the `Repair` switch and `Uninstaller` as the RepairBehavior, the repair command will use the uninstall command in the ARP `UninstallString` registry key, along with the repair switch, through a ShellExecute call, as long as `NoRepair` APR registry flag is not set to 1. - - Remote Source: If the YAML manifest file specifies the `Repair` switch and `Installer` valure for the RepairBehavior, the repair command will obtain the matching installer from the remote source and use the repair switch on the downloaded installer through a ShellExecute call.. - -> If neither switch is specified, the repair command will display an error message. - -> Note: The initial implementation will not support repair for Portables installer type. Based on feedback from the community, we may add the repair feature for these installer type in a future release. - -## Manifest Changes -Addition of `Repair` property to InstallerSwitch -- The `Repair` property is used to set the custom repair option that works with `RepairBehavior` field that controls the different repair behavior. - -Addition of `RepairBehavior` enumerable property to Installer Object -- With the `RepairBehavior` switch, we can adjust the repair behavior by choosing the installer source (Installed/local or remote) and making sure that the proper ARP registry entries are applied to identify the local installer type when carrying out a repair operation using a local installer source. -- The permitted initial values for the `RepairBehavior` switch include: - - Performing a repair using a Installed/Local Installer Source: - - `Modify`: if this option is specified, the repair switch will be applied to the `ModifyPath` ARP command entry, as long as `NoModify` and `NoRepair` ARP registry flags are not set to 1. - - `Uninstaller` : if this option is specified, the repair switch will be applied to the `UninstallString` ARP command entry, as long as `NoRepair` APR registry flag is note set to 1. - - Performing a repair using a Remote Installer Source: - - `Installer` : If this option is specified, the repair switch will be applied to the appropriate installer obtained from the remote installer source. - -## Manifest Validation -- Specifying `Repair` switch without `RepairBehavior` switch will result in an error. - - Specifying `RepairBehavior` switch without `Repair` switch will result in an error. - - `Repair` switch can't be empty when specified. - - `RepairBehavior` switch can't be empty when specified. - - -## Supported Repair Scenarios -- Repair for installed applications of Msi, Wix, Msix and MSStore installer types. -- Repair for the application using the custom repair switch specified in the YAML manifest file for Burn/Exe/Nullsoft/Inno/Wix/Msi installer types. - - The appropriate repair behavior is determined by the combination of the `Repair` switch and the `RepairBehavior` value in the YAML manifest. - -## Potential Issues -- For Burn/Exe/Nullsoft/Inno installer types - - the repair command will not work if the installer does not have a custom repair switch specified in the YAML manifest file. - - the repair command will not work if the installed Burn/Exe/Nullsoft/inno installer type doesn't correlate to the remote installer type that has a custom repair switch specified in the YAML manifest file. - -## Future considerations - -- Repair for Portables installer types. The possible options are: - - Download matching installer , uninstall & Install OR - - Download matching installer & re Install to overwrite existing files. -- Repair for Burn/Exe/Nullsoft/Inno installer types without custom repair switch. The possible options are: - - Download matching installer , uninstall & Install OR - - Download matching installer & re Install to overwrite existing files. - -## Resources -- https://learn.microsoft.com/en-us/windows/msix/desktop/managing-your-msix-reset-and-repair -- https://learn.microsoft.com/en-us/windows/win32/msi/reinstalling-a-feature-or-application -- https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#repair-options -- https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.store.preview.installcontrol.appinstallmanager.startproductinstallasync?view=winrt-22621 -- https://learn.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallproductw +--- +author: Madhusudhan Gumbalapura Sudarshan @Madhusudhan-MSFT +created on: 2023-12-01 +last updated: 2024-08-27 +issue id: 148 +--- + +# Repair Feature for Windows Package Manager + +"For [#148](https://github.com/microsoft/winget-cli/issues/148)" + +## Abstract + +This specification outlines the design and implementation of a repair feature for the Windows Package Manager.The repair feature aims to provide a convenient and reliable way for users to fix any issues that may arise with their installed applications, such as corrupted files, missing dependencies, or broken registry entries.The initial implementation will support repair for main installer types, such as Msi, Wix, Msix and MSStore installer types, which have native repair capabilities from their respective frameworks. Additionally, other installer types such as Burn/Exe/Nullsoft/Inno that can specify a custom repair switch in their YAML manifest files can also use the repair feature.The document also outlines the future plans for extending the repair feature to other installer types Portables that do not have a standard repair mechanism. + +## Inspiration + +The motivation for creating a repair feature in the Windows Package Manager is to provide users with a convenient and consistent way to fix their malfunctioning applications, regardless of the installer type. Currently, users have to rely on different methods to repair their applications, such as using the Windows Settings app, the Control Panel, the command line, or the application's own repair tool. These methods are not always available, accessible, or intuitive, and they may vary depending on the application and the installer type. The repair feature aims to provide a unified experience for users to repair their applications, regardless of the installer type. + +## Solution Design + +### Repair Command Syntax +`winget repair [[-q] ...] []` +will initiate the repair of the specified package. The command will display an error message if the application is not installed. The command will attempt to repair the application if it is installed. The command will display a success message if the repair succeeds. The command will display an error message if the repair fails. + +#### Arguments +| Argument | Description | +|-------------|-------------| +| **-q,--query** | The query used to search for an app. | + + +#### Optional Arguments + +| Option | Description | +|--------|-------------| +| **-m, --manifest** | Must be followed by the path to the manifest (YAML) file.You can use the manifest to run the repair experience from a [local manifest file](#local-repair).| +| **--id** | Limits the repair to the specified ID of the application.| +| **--name** | Limits the repair to the specified name of the application.| +| **--moniker** | Limits the repair to the specified moniker of the application.| +| **-v --version** | Limits the repair to the specified version of the application.If not specified, the repair will be applied to the latest version of the application.| +| **--architectures** | Select the architecture | +| **-s --source** | Limits the search to specified source(s).Must be followed by the source name.| +| **-o, --log** | Directs the logging to a log file. You must provide a path to a file that you have the write rights to. | +| **-i --interactive** | Runs the repair in interactive mode.| +| **-h --silent** | Runs the repair in silent mode.| +| **-?, --help** | Get additional help on this command. | +| **--accept-source-agreements** | Accept all source agreements during source operations | +| **--logs, --open-logs** | Open the default logs location. | +| **--locale** | Sets the locale.| + + +### Repair Feature for different Installer Types with Native Repair Capabilities + - Msi, Wix : The repair command will use the built-in repair features of the MSI installer type. It will run the msiexec command with the default [repair options](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#repair-options) to repair the application using a ShellExecute call. + - Msix : The repair command will use the built-in repair features of the MSIX installer type. It will make an MSIX API call to register the application package, which will attempt to repair the package. + > We can't do the same thing as setting app repair for MSIX app right now because we can't use the private APIs that it uses to do repair operations with winget. + - MSStore : The repair command will make an MSStore API [StartProductInstallAsync](https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.store.preview.installcontrol.appinstallmanager.startproductinstallasync?view=winrt-22621) call to repair the application with 'Repair' property of AppInstallOption set to true. + +### Repair Feature for Installer Types that require Custom Repair Switch + - Burn, Exe, Nullsoft & Inno : The custom switch for repair in the YAML manifest file will be used to perform the repair. The repair command will run the installer with the custom switch to repair the application. To have enough flexibility, different options are possible depending on the installer source used for repair. + - Installed Source: + - If the YAML manifest file specifies the `Repair` switch and `Modify` as the `RepairBehavior`, the repair command will use the modify command in the ARP `ModifyPath` registry key, along with the repair switch, through a ShellExecute call, as long as `NoModify` and `NoRepair` ARP registry flags are not set to 1. + - If the YAML manifest file specifies the `Repair` switch and `Uninstaller` as the RepairBehavior, the repair command will use the uninstall command in the ARP `UninstallString` registry key, along with the repair switch, through a ShellExecute call, as long as `NoRepair` APR registry flag is not set to 1. + - Remote Source: If the YAML manifest file specifies the `Repair` switch and `Installer` value for the RepairBehavior, the repair command will obtain the matching installer from the remote source and use the repair switch on the downloaded installer through a ShellExecute call.. + +> If neither switch is specified, the repair command will display an error message. + +> Note: The initial implementation will not support repair for Portables installer type. Based on feedback from the community, we may add the repair feature for these installer type in a future release. + +## Manifest Changes +Addition of `Repair` property to InstallerSwitch +- The `Repair` property is used to set the custom repair option that works with `RepairBehavior` field that controls the different repair behavior. + +Addition of `RepairBehavior` enumerable property to Installer Object +- With the `RepairBehavior` switch, we can adjust the repair behavior by choosing the installer source (Installed/local or remote) and making sure that the proper ARP registry entries are applied to identify the local installer type when carrying out a repair operation using a local installer source. +- The permitted initial values for the `RepairBehavior` switch include: + - Performing a repair using a Installed/Local Installer Source: + - `Modify`: if this option is specified, the repair switch will be applied to the `ModifyPath` ARP command entry, as long as `NoModify` and `NoRepair` ARP registry flags are not set to 1. + - `Uninstaller` : if this option is specified, the repair switch will be applied to the `UninstallString` ARP command entry, as long as `NoRepair` APR registry flag is note set to 1. + - Performing a repair using a Remote Installer Source: + - `Installer` : If this option is specified, the repair switch will be applied to the appropriate installer obtained from the remote installer source. + +## Manifest Validation +- Specifying `Repair` switch without `RepairBehavior` switch will result in an error. + - Specifying `RepairBehavior` switch without `Repair` switch will result in an error. + - `Repair` switch can't be empty when specified. + - `RepairBehavior` switch can't be empty when specified. + +## Handling Elevation Requirement +- The design presumes that the elevation requirements for modification/repair are consistent with those for installation, much like uninstallation. +- The expectations are: + - If a non-elevated session tries to modify a package installed for machine scope, the installer should prompt for elevation, as observed in sample runs. + - If a package installed for user scope attempts a repair operation in an admin context, it is restricted due to possible security risks. + +## Supported Repair Scenarios +- Repair for installed applications of Msi, Wix, Msix and MSStore installer types. +- Repair for the application using the custom repair switch specified in the YAML manifest file for Burn/Exe/Nullsoft/Inno/Wix/Msi installer types. + - The appropriate repair behavior is determined by the combination of the `Repair` switch and the `RepairBehavior` value in the YAML manifest. + +## Potential Issues +- For Msi based installer types + - To repair an Msi-based installer using msiexec platform support, the original installer must be present at the location registered as 'InstallSource' in the ARP registry. If the original installer is moved or renamed, the repair operation will fail, which is consistent with the modify repair through the settings app. This issue is more likely with installers installed via the winget install command, as it removes the installer right after installation to reduce disk footprint by design, making the 'InstallSource' path invalid. However, this issue does not apply if the installer can store the installer in a package cache path for future use and registers that path in 'InstallSource' in the ARP registry at the time of installation. +- For Burn/Exe/Nullsoft/Inno installer types + - the repair command will not work if the installer does not have a custom repair switch specified in the YAML manifest file. + - the repair command will not work if the installed Burn/Exe/Nullsoft/inno installer type doesn't correlate to the remote installer type that has a custom repair switch specified in the YAML manifest file. + +## Future considerations + +- Repair for Portables installer types. The possible options are: + - Download matching installer , uninstall & Install OR + - Download matching installer & re Install to overwrite existing files. +- Repair for Burn/Exe/Nullsoft/Inno installer types without custom repair switch. The possible options are: + - Download matching installer , uninstall & Install OR + - Download matching installer & re Install to overwrite existing files. + +## Resources +- https://learn.microsoft.com/en-us/windows/msix/desktop/managing-your-msix-reset-and-repair +- https://learn.microsoft.com/en-us/windows/win32/msi/reinstalling-a-feature-or-application +- https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#repair-options +- https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.store.preview.installcontrol.appinstallmanager.startproductinstallasync?view=winrt-22621 +- https://learn.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallproductw