@@ -21,6 +21,7 @@ public class WinGetPackageManager : WinGetInfo
2121 private const string _searchCmd = "search {0} --accept-source-agreements" ;
2222 private const string _installCmd = "install {0}" ;
2323 private const string _upgradeCmd = "upgrade {0}" ;
24+ private const string _upgradeAllCmd = "upgrade --all" ;
2425 private const string _getUpgradeableCmd = "upgrade" ;
2526 private const string _includeUnknown = "--include-unknown" ;
2627 private const string _uninstallCmd = "uninstall {0}" ;
@@ -735,6 +736,76 @@ public async Task<bool> UpgradePackageAsync(WinGetPackage package)
735736 return await UpgradePackageAsync ( package . PackageId ) ;
736737 }
737738
739+ /// <summary>
740+ /// Tries to upgrade all packages using winget.
741+ /// </summary>
742+ /// <remarks>
743+ /// The action might run succesfully without upgrading every or even any package.
744+ /// </remarks>
745+ /// <returns>
746+ /// <see langword="true"/> if the action run successfully or <see langword="false"/> if it failed.
747+ /// </returns>
748+ /// <exception cref="WGetNET.WinGetNotInstalledException">
749+ /// WinGet is not installed or not found on the system.
750+ /// </exception>
751+ /// <exception cref="WGetNET.WinGetActionFailedException">
752+ /// The current action failed for an unexpected reason.
753+ /// Please see inner exception.
754+ /// </exception>
755+ public bool UpgradeAllPackages ( )
756+ {
757+ try
758+ {
759+ ProcessResult result =
760+ _processManager . ExecuteWingetProcess ( _upgradeAllCmd ) ;
761+
762+ return result . Success ;
763+ }
764+ catch ( Win32Exception )
765+ {
766+ throw new WinGetNotInstalledException ( ) ;
767+ }
768+ catch ( Exception e )
769+ {
770+ throw new WinGetActionFailedException ( "Upgrading all packages failed." , e ) ;
771+ }
772+ }
773+
774+ /// <summary>
775+ /// Asynchronously tries to upgrade all packages using winget.
776+ /// </summary>
777+ /// <remarks>
778+ /// The action might run succesfully without upgrading every or even any package.
779+ /// </remarks>
780+ /// <returns>
781+ /// <see langword="true"/> if the action run successfully or <see langword="false"/> if it failed.
782+ /// </returns>
783+ /// <exception cref="WGetNET.WinGetNotInstalledException">
784+ /// WinGet is not installed or not found on the system.
785+ /// </exception>
786+ /// <exception cref="WGetNET.WinGetActionFailedException">
787+ /// The current action failed for an unexpected reason.
788+ /// Please see inner exception.
789+ /// </exception>
790+ public async Task < bool > UpgradeAllPackagesAsync ( )
791+ {
792+ try
793+ {
794+ ProcessResult result =
795+ await _processManager . ExecuteWingetProcessAsync ( _upgradeAllCmd ) ;
796+
797+ return result . Success ;
798+ }
799+ catch ( Win32Exception )
800+ {
801+ throw new WinGetNotInstalledException ( ) ;
802+ }
803+ catch ( Exception e )
804+ {
805+ throw new WinGetActionFailedException ( "Upgrading all packages failed." , e ) ;
806+ }
807+ }
808+
738809 private string AddArgumentByVersion ( string argument )
739810 {
740811 // Checking version to determine if "--include-unknown" is necessary
0 commit comments