@@ -1390,6 +1390,48 @@ public bool RepairPackage(string packageId)
13901390 return result . Success ;
13911391 }
13921392
1393+ /// <summary>
1394+ /// Repairs a package using winget.
1395+ /// </summary>
1396+ /// <remarks>Limited to packages with an installer that supports this function.</remarks>
1397+ /// <param name="packageId">The id or name of the package for the repair action.</param>
1398+ /// <param name="silent">Request silent package repair.</param>
1399+ /// <returns>
1400+ /// <see langword="true"/> if the repair action was successful or <see langword="false"/> if it failed.
1401+ /// </returns>
1402+ /// <exception cref="WGetNET.Exceptions.WinGetNotInstalledException">
1403+ /// WinGet is not installed or not found on the system.
1404+ /// </exception>
1405+ /// <exception cref="WGetNET.Exceptions.WinGetFeatureNotSupportedException">
1406+ /// This feature is not supported in the installed WinGet version.
1407+ /// </exception>
1408+ /// <exception cref="System.ArgumentException">
1409+ /// A provided argument is empty.
1410+ /// </exception>
1411+ /// <exception cref="System.ArgumentNullException">
1412+ /// A provided argument is null.
1413+ /// </exception>
1414+ public bool RepairPackage ( string packageId , bool silent )
1415+ {
1416+ if ( ! CheckWinGetVersion ( _repairMinVersion ) )
1417+ {
1418+ throw new WinGetFeatureNotSupportedException ( _repairMinVersion ) ;
1419+ }
1420+
1421+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( packageId , "packageId" ) ;
1422+
1423+ string cmd = string . Format ( _repairCmd , packageId ) ;
1424+
1425+ if ( silent )
1426+ {
1427+ cmd = Silent ( cmd ) ;
1428+ }
1429+
1430+ ProcessResult result = Execute ( cmd ) ;
1431+
1432+ return result . Success ;
1433+ }
1434+
13931435 /// <summary>
13941436 /// Repairs a package using winget.
13951437 /// </summary>
@@ -1422,6 +1464,39 @@ public bool RepairPackage(WinGetPackage package)
14221464 return RepairPackage ( package . Id ) ;
14231465 }
14241466
1467+ /// <summary>
1468+ /// Repairs a package using winget.
1469+ /// </summary>
1470+ /// <remarks>Limited to packages with an installer that supports this function.</remarks>
1471+ /// <param name="package">The <see cref="WGetNET.WinGetPackage"/> for the repair action.</param>
1472+ /// <param name="silent">Request silent package repair.</param>
1473+ /// <returns>
1474+ /// <see langword="true"/> if the repair action was successful or <see langword="false"/> if it failed.
1475+ /// </returns>
1476+ /// <exception cref="WGetNET.Exceptions.WinGetNotInstalledException">
1477+ /// WinGet is not installed or not found on the system.
1478+ /// </exception>
1479+ /// <exception cref="WGetNET.Exceptions.WinGetFeatureNotSupportedException">
1480+ /// This feature is not supported in the installed WinGet version.
1481+ /// </exception>
1482+ /// <exception cref="System.ArgumentException">
1483+ /// A provided argument is empty.
1484+ /// </exception>
1485+ /// <exception cref="System.ArgumentNullException">
1486+ /// A provided argument is null.
1487+ /// </exception>
1488+ public bool RepairPackage ( WinGetPackage package , bool silent )
1489+ {
1490+ ArgsHelper . ThrowIfWinGetObjectIsNullOrEmpty ( package , "package" ) ;
1491+
1492+ if ( package . HasShortenedId || package . HasNoId )
1493+ {
1494+ return RepairPackage ( package . Name , silent ) ;
1495+ }
1496+
1497+ return RepairPackage ( package . Id , silent ) ;
1498+ }
1499+
14251500 /// <summary>
14261501 /// Asynchronously repairs a package using winget.
14271502 /// </summary>
@@ -1462,6 +1537,52 @@ public async Task<bool> RepairPackageAsync(string packageId, CancellationToken c
14621537 return result . Success ;
14631538 }
14641539
1540+ /// <summary>
1541+ /// Asynchronously repairs a package using winget.
1542+ /// </summary>
1543+ /// <remarks>Limited to packages with an installer that supports this function.</remarks>
1544+ /// <param name="packageId">The id or name of the package for the repair action.</param>
1545+ /// <param name="silent">Request silent package repair.</param>
1546+ /// <param name="cancellationToken">
1547+ /// The <see cref="System.Threading.CancellationToken"/> for the <see cref="System.Threading.Tasks.Task"/>.
1548+ /// </param>
1549+ /// <returns>
1550+ /// A <see cref="System.Threading.Tasks.Task"/>, containing the result.
1551+ /// The result is <see langword="true"/> if the repair action was successful or <see langword="false"/> if it failed.
1552+ /// </returns>
1553+ /// <exception cref="WGetNET.Exceptions.WinGetNotInstalledException">
1554+ /// WinGet is not installed or not found on the system.
1555+ /// </exception>
1556+ /// <exception cref="WGetNET.Exceptions.WinGetFeatureNotSupportedException">
1557+ /// This feature is not supported in the installed WinGet version.
1558+ /// </exception>
1559+ /// <exception cref="System.ArgumentException">
1560+ /// A provided argument is empty.
1561+ /// </exception>
1562+ /// <exception cref="System.ArgumentNullException">
1563+ /// A provided argument is null.
1564+ /// </exception>
1565+ public async Task < bool > RepairPackageAsync ( string packageId , bool silent , CancellationToken cancellationToken = default )
1566+ {
1567+ if ( ! CheckWinGetVersion ( _repairMinVersion ) )
1568+ {
1569+ throw new WinGetFeatureNotSupportedException ( _repairMinVersion ) ;
1570+ }
1571+
1572+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( packageId , "packageId" ) ;
1573+
1574+ string cmd = string . Format ( _repairCmd , packageId ) ;
1575+
1576+ if ( silent )
1577+ {
1578+ cmd = Silent ( cmd ) ;
1579+ }
1580+
1581+ ProcessResult result = await ExecuteAsync ( cmd , false , cancellationToken ) ;
1582+
1583+ return result . Success ;
1584+ }
1585+
14651586 /// <summary>
14661587 /// Asynchronously repair a package using winget.
14671588 /// </summary>
@@ -1497,6 +1618,43 @@ public async Task<bool> RepairPackageAsync(WinGetPackage package, CancellationTo
14971618
14981619 return await RepairPackageAsync ( package . Id , cancellationToken ) ;
14991620 }
1621+
1622+ /// <summary>
1623+ /// Asynchronously repair a package using winget.
1624+ /// </summary>
1625+ /// <remarks>Limited to packages with an installer that supports this function.</remarks>
1626+ /// <param name="package">The <see cref="WGetNET.WinGetPackage"/> for the repair action.</param>
1627+ /// <param name="silent">Request silent package repair.</param>
1628+ /// <param name="cancellationToken">
1629+ /// The <see cref="System.Threading.CancellationToken"/> for the <see cref="System.Threading.Tasks.Task"/>.
1630+ /// </param>
1631+ /// <returns>
1632+ /// A <see cref="System.Threading.Tasks.Task"/>, containing the result.
1633+ /// The result is <see langword="true"/> if the repair action was successful or <see langword="false"/> if it failed.
1634+ /// </returns>
1635+ /// <exception cref="WGetNET.Exceptions.WinGetNotInstalledException">
1636+ /// WinGet is not installed or not found on the system.
1637+ /// </exception>
1638+ /// <exception cref="WGetNET.Exceptions.WinGetFeatureNotSupportedException">
1639+ /// This feature is not supported in the installed WinGet version.
1640+ /// </exception>
1641+ /// <exception cref="System.ArgumentException">
1642+ /// A provided argument is empty.
1643+ /// </exception>
1644+ /// <exception cref="System.ArgumentNullException">
1645+ /// A provided argument is null.
1646+ /// </exception>
1647+ public async Task < bool > RepairPackageAsync ( WinGetPackage package , bool silent , CancellationToken cancellationToken = default )
1648+ {
1649+ ArgsHelper . ThrowIfWinGetObjectIsNullOrEmpty ( package , "package" ) ;
1650+
1651+ if ( package . HasShortenedId || package . HasNoId )
1652+ {
1653+ return await RepairPackageAsync ( package . Name , silent , cancellationToken ) ;
1654+ }
1655+
1656+ return await RepairPackageAsync ( package . Id , silent , cancellationToken ) ;
1657+ }
15001658 //---------------------------------------------------------------------------------------------
15011659
15021660 //---Export and Import-------------------------------------------------------------------------
0 commit comments