@@ -19,6 +19,7 @@ public class WinGetPackageManager : WinGetInfo
1919 private const string _installCmd = "install {0}" ;
2020 private const string _upgradeCmd = "upgrade {0}" ;
2121 private const string _getUpgradeableCmd = "upgrade" ;
22+ private const string _includeUnknown = "--include-unknown" ;
2223 private const string _uninstallCmd = "uninstall {0}" ;
2324 private const string _exportCmd = "export -o {0}" ;
2425 private const string _importCmd = "import -i {0} --ignore-unavailable" ;
@@ -207,7 +208,7 @@ public bool UninstallPackage(string packageId)
207208 }
208209
209210 /// <summary>
210- /// Uninsatll a package using winget.
211+ /// Uninstall a package using winget.
211212 /// </summary>
212213 /// <param name="package">The <see cref="WGetNET.WinGetPackage"/> for the uninstallation.</param>
213214 /// <returns>
@@ -259,8 +260,20 @@ public List<WinGetPackage> GetUpgradeablePackages()
259260 {
260261 try
261262 {
263+ string argument = _getUpgradeableCmd ;
264+
265+ // Checking version to determine if "--include-unknown" is necessary
266+ int wingetVersion = 0 ;
267+ bool castSuccessful = int . TryParse ( WinGetVersion . Split ( "-" ) [ 0 ] . Replace ( "v" , "" ) . Replace ( "." , "" ) , out wingetVersion ) ;
268+
269+ if ( castSuccessful && wingetVersion >= 142161 )
270+ {
271+ // Winget version supports new argument, add "--include-unknown" to arguments
272+ argument += " " + _includeUnknown ;
273+ }
274+
262275 ProcessResult result =
263- _processManager . ExecuteWingetProcess ( _getUpgradeableCmd ) ;
276+ _processManager . ExecuteWingetProcess ( argument ) ;
264277
265278 return ProcessOutputReader . ToPackageList ( result . Output ) ;
266279 }
0 commit comments