6using System.Collections.Generic;
9using System.Threading.Tasks;
22 private readonly
Version _downloadMinVersion =
new(1, 6, 0);
23 private readonly
Version _repairMinVersion =
new(1, 7, 0);
24 private readonly
Version _pinMinVersion =
new(1, 5, 0);
54 public List<WinGetPackage>
SearchPackage(
string packageId,
bool exact =
false)
56 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
65 ProcessResult result = Execute(cmd);
67 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.Search);
92 public List<WinGetPackage>
SearchPackage(
string packageId,
string sourceName,
bool exact =
false)
94 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
95 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(sourceName,
"sourceName");
104 ProcessResult result = Execute(cmd);
106 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.SearchBySource, sourceName);
132 public async Task<List<WinGetPackage>>
SearchPackageAsync(
string packageId,
bool exact =
false, CancellationToken cancellationToken =
default)
134 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
143 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
146 if (cancellationToken.IsCancellationRequested)
148 return new List<WinGetPackage>();
151 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.Search);
180 public async Task<List<WinGetPackage>>
SearchPackageAsync(
string packageId,
string sourceName,
bool exact =
false, CancellationToken cancellationToken =
default)
182 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
183 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(sourceName,
"sourceName");
192 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
195 if (cancellationToken.IsCancellationRequested)
197 return new List<WinGetPackage>();
200 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.SearchBySource, sourceName);
218 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.InstalledList);
242 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
251 ProcessResult result = Execute(cmd);
253 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.InstalledList);
280 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
281 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(sourceName,
"sourceName");
290 ProcessResult result = Execute(cmd);
292 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.InstalledListBySource, sourceName);
313 if (cancellationToken.IsCancellationRequested)
315 return new List<WinGetPackage>();
318 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.InstalledList);
344 public async Task<List<WinGetPackage>>
GetInstalledPackagesAsync(
string packageId,
bool exact =
false, CancellationToken cancellationToken =
default)
346 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
355 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
358 if (cancellationToken.IsCancellationRequested)
360 return new List<WinGetPackage>();
363 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.InstalledList);
392 public async Task<List<WinGetPackage>>
GetInstalledPackagesAsync(
string packageId,
string sourceName,
bool exact =
false, CancellationToken cancellationToken =
default)
394 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
395 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(sourceName,
"sourceName");
404 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
407 if (cancellationToken.IsCancellationRequested)
409 return new List<WinGetPackage>();
412 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.InstalledListBySource, sourceName);
438 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
442 return PackageHelper.MatchExact(
443 ProcessOutputReader.ToPackageList(result.Output, PackageAction.InstalledList),
474 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
475 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(sourceName,
"sourceName");
479 return PackageHelper.MatchExact(
480 ProcessOutputReader.ToPackageList(result.Output, PackageAction.InstalledList),
511 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
516 if (cancellationToken.IsCancellationRequested)
521 return PackageHelper.MatchExact(
522 ProcessOutputReader.ToPackageList(result.Output, PackageAction.InstalledList),
556 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
557 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(sourceName,
"sourceName");
559 ProcessResult result =
562 false, cancellationToken);
565 if (cancellationToken.IsCancellationRequested)
570 return PackageHelper.MatchExact(
571 ProcessOutputReader.ToPackageList(result.Output, PackageAction.InstalledList),
596 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
600 return result.Success;
622 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
631 ProcessResult result = Execute(cmd);
633 return result.Success;
654 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
683 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
713 public async Task<bool>
InstallPackageAsync(
string packageId, CancellationToken cancellationToken =
default)
715 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
717 ProcessResult result =
720 false, cancellationToken);
722 return result.Success;
746 public async Task<bool>
InstallPackageAsync(
string packageId,
bool silent, CancellationToken cancellationToken =
default)
748 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
757 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
759 return result.Success;
784 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
817 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
847 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
851 return result.Success;
873 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
882 ProcessResult result = Execute(cmd);
884 return result.Success;
905 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
934 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
966 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
970 return result.Success;
994 public async Task<bool>
UninstallPackageAsync(
string packageId,
bool silent, CancellationToken cancellationToken =
default)
996 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
1005 ProcessResult result =
1006 await ExecuteAsync(cmd,
false, cancellationToken);
1008 return result.Success;
1033 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
1066 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
1090 IncludeUnknownbyVersion(
1093 ProcessResult result = Execute(cmd);
1095 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.UpgradeList);
1114 IncludeUnknownbyVersion(
1117 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
1120 if (cancellationToken.IsCancellationRequested)
1122 return new List<WinGetPackage>();
1125 return ProcessOutputReader.ToPackageList(result.Output, PackageAction.UpgradeList);
1148 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
1152 return result.Success;
1174 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
1183 ProcessResult result = Execute(cmd);
1185 return result.Success;
1206 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
1235 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
1267 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
1269 ProcessResult result =
1272 false, cancellationToken);
1274 return result.Success;
1298 public async Task<bool>
UpgradePackageAsync(
string packageId,
bool silent, CancellationToken cancellationToken =
default)
1300 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
1309 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
1311 return result.Success;
1336 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
1369 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
1395 return result.Success;
1420 ProcessResult result = Execute(cmd);
1422 return result.Success;
1443 ProcessResult result =
1446 false, cancellationToken);
1448 return result.Success;
1477 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
1479 return result.Success;
1506 if (!CheckWinGetVersion(_repairMinVersion))
1511 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
1515 return result.Success;
1541 if (!CheckWinGetVersion(_repairMinVersion))
1546 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
1555 ProcessResult result = Execute(cmd);
1557 return result.Success;
1582 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
1615 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
1649 public async Task<bool>
RepairPackageAsync(
string packageId, CancellationToken cancellationToken =
default)
1651 if (!CheckWinGetVersion(_repairMinVersion))
1656 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
1658 ProcessResult result =
1663 .AcceptSourceAgreements()
1664 .AcceptPackageAgreements(),
1665 false, cancellationToken);
1667 return result.Success;
1695 public async Task<bool>
RepairPackageAsync(
string packageId,
bool silent, CancellationToken cancellationToken =
default)
1697 if (!CheckWinGetVersion(_repairMinVersion))
1702 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
1711 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
1713 return result.Success;
1742 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
1779 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
1809 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(file,
"file");
1813 return result.Success;
1838 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(file,
"file");
1840 ProcessResult result =
1843 return result.Success;
1868 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(file,
"file");
1870 ProcessResult result =
1875 .IgnoreUnavailable()
1876 .AcceptSourceAgreements()
1877 .AcceptPackageAgreements());
1879 return result.Success;
1908 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(file,
"file");
1910 ProcessResult result =
1915 .IgnoreUnavailable()
1916 .AcceptSourceAgreements()
1917 .AcceptPackageAgreements(),
1918 false, cancellationToken);
1920 return result.Success;
1948 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(file,
"file");
1950 if (!File.Exists(file))
1952 throw new FileNotFoundException($
"Unable to find the specified file. File:'{file}'");
1957 if (!result.Success)
1959 return string.Empty;
1962 return ProcessOutputReader.ResultToHash(result);
1985 ArgsHelper.ThrowIfObjectIsNull(file,
"file");
1989 throw new FileNotFoundException($
"Unable to find the specified file. File:'{file.FullName}'");
1992 return Hash(file.FullName);
2020 public async Task<string>
HashAsync(
string file, CancellationToken cancellationToken =
default)
2022 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(file,
"file");
2024 if (!File.Exists(file))
2026 throw new FileNotFoundException($
"Unable to find the specified file. File:'{file}'");
2031 if (!result.Success || cancellationToken.IsCancellationRequested)
2033 return string.Empty;
2036 return ProcessOutputReader.ResultToHash(result);
2061 public async Task<string>
HashAsync(FileInfo file, CancellationToken cancellationToken =
default)
2063 ArgsHelper.ThrowIfObjectIsNull(file,
"file");
2067 throw new FileNotFoundException($
"Unable to find the specified file. File:'{file.FullName}'");
2070 return await
HashAsync(file.FullName, cancellationToken);
2095 public bool Download(
string packageId,
string directory)
2097 if (!CheckWinGetVersion(_downloadMinVersion))
2102 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
2103 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(directory,
"directory");
2105 ProcessResult result =
2110 .Directory(directory)
2111 .AcceptSourceAgreements()
2112 .AcceptPackageAgreements());
2114 return result.Success;
2140 public bool Download(
string packageId, DirectoryInfo directory)
2142 ArgsHelper.ThrowIfObjectIsNull(directory,
"directory");
2144 return Download(packageId, directory.FullName);
2169 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
2204 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
2205 ArgsHelper.ThrowIfObjectIsNull(directory,
"directory");
2212 return Download(package.
Id, directory.FullName);
2239 public async Task<bool>
DownloadAsync(
string packageId,
string directory, CancellationToken cancellationToken =
default)
2241 if (!CheckWinGetVersion(_downloadMinVersion))
2246 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
2247 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(directory,
"directory");
2249 ProcessResult result =
2254 .Directory(directory)
2255 .AcceptSourceAgreements()
2256 .AcceptPackageAgreements(),
2257 false, cancellationToken);
2259 return result.Success;
2289 public async Task<bool>
DownloadAsync(
string packageId, DirectoryInfo directory, CancellationToken cancellationToken =
default)
2291 ArgsHelper.ThrowIfObjectIsNull(directory,
"directory");
2293 return await
DownloadAsync(packageId, directory.FullName, cancellationToken);
2322 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
2361 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
2362 ArgsHelper.ThrowIfObjectIsNull(directory,
"directory");
2366 return await
DownloadAsync(package.
Name, directory.FullName, cancellationToken);
2369 return await
DownloadAsync(package.
Id, directory.FullName, cancellationToken);
2388 if (!CheckWinGetVersion(_pinMinVersion))
2395 return ProcessOutputReader.ToPinnedPackageList(result.Output);
2416 if (!CheckWinGetVersion(_pinMinVersion))
2424 if (cancellationToken.IsCancellationRequested)
2426 return new List<WinGetPinnedPackage>();
2429 return ProcessOutputReader.ToPinnedPackageList(result.Output);
2454 public bool PinAdd(
string packageId,
bool blocking =
false)
2456 if (!CheckWinGetVersion(_pinMinVersion))
2461 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
2470 ProcessResult result = Execute(cmd);
2472 return result.Success;
2498 public bool PinAdd(
string packageId,
string version)
2500 if (!CheckWinGetVersion(_pinMinVersion))
2505 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
2506 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(version,
"version");
2510 return result.Success;
2535 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
2542 return PinAdd(package.
Id, blocking);
2570 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
2577 return PinAdd(package.
Id, version);
2604 public async Task<bool>
PinAddAsync(
string packageId,
bool blocking =
false, CancellationToken cancellationToken =
default)
2606 if (!CheckWinGetVersion(_pinMinVersion))
2611 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
2620 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
2622 return result.Success;
2652 public async Task<bool>
PinAddAsync(
string packageId,
string version, CancellationToken cancellationToken =
default)
2654 if (!CheckWinGetVersion(_pinMinVersion))
2659 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
2660 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(version,
"version");
2664 return result.Success;
2693 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
2700 return await
PinAddAsync(package.
Id, blocking, cancellationToken);
2732 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
2739 return await
PinAddAsync(package.
Id, version, cancellationToken);
2764 if (!CheckWinGetVersion(_pinMinVersion))
2769 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
2778 ProcessResult result = Execute(cmd);
2780 return result.Success;
2808 if (!CheckWinGetVersion(_pinMinVersion))
2813 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
2814 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(version,
"version");
2818 return result.Success;
2843 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
2878 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
2912 public async Task<bool>
PinAddInstalledAsync(
string packageId,
bool blocking =
false, CancellationToken cancellationToken =
default)
2914 if (!CheckWinGetVersion(_pinMinVersion))
2919 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
2928 ProcessResult result = await ExecuteAsync(cmd,
false, cancellationToken);
2930 return result.Success;
2960 public async Task<bool>
PinAddInstalledAsync(
string packageId,
string version, CancellationToken cancellationToken =
default)
2962 if (!CheckWinGetVersion(_pinMinVersion))
2967 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
2968 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(version,
"version");
2970 ProcessResult result =
2973 false, cancellationToken);
2975 return result.Success;
3004 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
3043 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
3076 if (!CheckWinGetVersion(_pinMinVersion))
3081 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
3085 return result.Success;
3109 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
3142 public async Task<bool>
PinRemoveAsync(
string packageId, CancellationToken cancellationToken =
default)
3144 if (!CheckWinGetVersion(_pinMinVersion))
3149 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
3153 return result.Success;
3181 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
3212 if (!CheckWinGetVersion(_pinMinVersion))
3217 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
3221 return result.Success;
3245 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
3280 if (!CheckWinGetVersion(_pinMinVersion))
3285 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(packageId,
"packageId");
3289 return result.Success;
3317 ArgsHelper.ThrowIfWinGetObjectIsNullOrEmpty(package,
"package");
3346 if (!CheckWinGetVersion(_pinMinVersion))
3353 return result.Success;
3375 public async Task<bool>
ResetPinsAsync(CancellationToken cancellationToken =
default)
3377 if (!CheckWinGetVersion(_pinMinVersion))
3384 return result.Success;
3402 if (CheckWinGetVersion(
new Version(1, 4, 0)))
The WGetNET.WinGet class offers informations about the installed winget version.
Version Version
Gets the version number of the winget installation.
The WGetNET.WinGetPackageManager class offers methods to manage packages with winget.
async Task< bool > UpgradePackageAsync(WinGetPackage package, bool silent, CancellationToken cancellationToken=default)
Asynchronously upgrades a package using winget.
async Task< bool > DownloadAsync(WinGetPackage package, DirectoryInfo directory, CancellationToken cancellationToken=default)
Asynchronously downloads the installer of a package using winget.
async Task< bool > PinAddAsync(string packageId, bool blocking=false, CancellationToken cancellationToken=default)
Asynchronously adds a pinned package to winget.
async Task< bool > UpgradePackageAsync(string packageId, CancellationToken cancellationToken=default)
Asynchronously upgrades a package using winget.
async Task< bool > RepairPackageAsync(string packageId, CancellationToken cancellationToken=default)
Asynchronously repairs a package using winget.
async Task< bool > PinAddInstalledAsync(WinGetPackage package, bool blocking=false, CancellationToken cancellationToken=default)
Asynchronously adds a pinned installed package to winget.
async Task< bool > InstallPackageAsync(string packageId, bool silent, CancellationToken cancellationToken=default)
Asynchronously install a package using winget.
async Task< bool > PinAddInstalledAsync(string packageId, string version, CancellationToken cancellationToken=default)
Asynchronously adds a pinned installed package to winget.
async Task< bool > RepairPackageAsync(WinGetPackage package, CancellationToken cancellationToken=default)
Asynchronously repair a package using winget.
bool InstallPackage(WinGetPackage package, bool silent)
Install a package using winget.
bool UninstallPackage(string packageId)
Uninsatll a package using winget.
bool UpgradeAllPackages()
Tries to upgrade all packages using winget.
async Task< WinGetPackage?> GetExactInstalledPackageAsync(string packageId, string sourceName, CancellationToken cancellationToken=default)
Asynchronously gets a installed package, that matchs the provided id/name. If there are multiple matc...
bool RepairPackage(WinGetPackage package)
Repairs a package using winget.
async Task< WinGetPackage?> GetExactInstalledPackageAsync(string packageId, CancellationToken cancellationToken=default)
Asynchronously gets a installed package, that matchs the provided id/name. If there are multiple matc...
async Task< bool > PinRemoveAsync(string packageId, CancellationToken cancellationToken=default)
Asynchronously removes a pinned package from winget.
List< WinGetPinnedPackage > GetPinnedPackages()
Gets a list of all pinned packages.
bool PinRemove(WinGetPackage package)
Removes a pinned package from winget.
bool UninstallPackage(string packageId, bool silent)
Uninsatll a package using winget.
bool RepairPackage(string packageId)
Repairs a package using winget.
async Task< List< WinGetPackage > > GetUpgradeablePackagesAsync(CancellationToken cancellationToken=default)
Asynchronously get all upgradeable packages.
async Task< bool > DownloadAsync(string packageId, string directory, CancellationToken cancellationToken=default)
Asynchronously downloads the installer of a package using winget.
bool PinRemoveInstalled(string packageId)
Removes a pinned package from winget.
bool PinRemove(string packageId)
Removes a pinned package from winget.
async Task< bool > PinAddInstalledAsync(string packageId, bool blocking=false, CancellationToken cancellationToken=default)
Asynchronously adds a pinned installed package to winget.
async Task< bool > InstallPackageAsync(WinGetPackage package, CancellationToken cancellationToken=default)
Asynchronously install a package using winget.
async Task< bool > RepairPackageAsync(string packageId, bool silent, CancellationToken cancellationToken=default)
Asynchronously repairs a package using winget.
List< WinGetPackage > GetInstalledPackages(string packageId, bool exact=false)
Gets a list of all installed packages. That match the provided name.
bool Download(WinGetPackage package, DirectoryInfo directory)
Downloads the installer of a package using winget.
bool UpgradePackage(string packageId)
Upgrades a package using winget.
bool PinAddInstalled(WinGetPackage package, bool blocking=false)
Adds a pinned installed package to winget.
async Task< bool > InstallPackageAsync(string packageId, CancellationToken cancellationToken=default)
Asynchronously install a package using winget.
List< WinGetPackage > GetInstalledPackages(string packageId, string sourceName, bool exact=false)
Gets a list of all installed packages. That match the provided name.
async Task< bool > UpgradePackageAsync(WinGetPackage package, CancellationToken cancellationToken=default)
Asynchronously upgrades a package using winget.
async Task< bool > UninstallPackageAsync(WinGetPackage package, CancellationToken cancellationToken=default)
Asynchronously uninstall a package using winget.
async Task< bool > DownloadAsync(WinGetPackage package, string directory, CancellationToken cancellationToken=default)
Asynchronously downloads the installer of a package using winget.
string Hash(FileInfo file)
Executes the WinGet hash function, to calculate the hash for the given file.
async Task< List< WinGetPackage > > SearchPackageAsync(string packageId, string sourceName, bool exact=false, CancellationToken cancellationToken=default)
Uses the winget search function to asynchronously search for a package that maches the given name.
async Task< bool > PinAddAsync(string packageId, string version, CancellationToken cancellationToken=default)
Asynchronously adds a pinned package to winget.
async Task< bool > PinAddInstalledAsync(WinGetPackage package, string version, CancellationToken cancellationToken=default)
Asynchronously adds a pinned installed package to winget.
bool ExportPackagesToFile(string file)
Exports a list of all installed winget packages as json to the given file.
async Task< bool > UpgradePackageAsync(string packageId, bool silent, CancellationToken cancellationToken=default)
Asynchronously upgrades a package using winget.
bool UpgradePackage(WinGetPackage package)
Upgrades a package using winget.
async Task< List< WinGetPackage > > SearchPackageAsync(string packageId, bool exact=false, CancellationToken cancellationToken=default)
Uses the winget search function to asynchronously search for a package that maches the given name.
async Task< bool > ExportPackagesToFileAsync(string file, CancellationToken cancellationToken=default)
Asynchronously exports a list of all installed winget packages as json to the given file.
async Task< bool > ResetPinsAsync(CancellationToken cancellationToken=default)
Asynchronously resets all pinned packages.
bool InstallPackage(string packageId)
Install a package using winget.
async Task< List< WinGetPackage > > GetInstalledPackagesAsync(string packageId, string sourceName, bool exact=false, CancellationToken cancellationToken=default)
Asynchronously gets a list of all installed packages. That match the provided name.
bool Download(string packageId, string directory)
Downloads the installer of a package using winget.
bool ResetPins()
Resets all pinned packages.
async Task< bool > UninstallPackageAsync(string packageId, bool silent, CancellationToken cancellationToken=default)
Asynchronously uninsatll a package using winget.
async Task< bool > PinRemoveInstalledAsync(WinGetPackage package, CancellationToken cancellationToken=default)
Asynchronously removes a pinned package from winget.
async Task< List< WinGetPackage > > GetInstalledPackagesAsync(CancellationToken cancellationToken=default)
Asynchronously gets a list of all installed packages.
bool UninstallPackage(WinGetPackage package, bool silent)
Uninstall a package using winget.
bool InstallPackage(string packageId, bool silent)
Install a package using winget.
async Task< bool > PinAddAsync(WinGetPackage package, bool blocking=false, CancellationToken cancellationToken=default)
Asynchronously adds a pinned package to winget.
async Task< bool > PinRemoveInstalledAsync(string packageId, CancellationToken cancellationToken=default)
Asynchronously removes a pinned package from winget.
async Task< bool > UpgradeAllPackagesAsync(bool silent, CancellationToken cancellationToken=default)
Asynchronously tries to upgrade all packages using winget.
async Task< bool > RepairPackageAsync(WinGetPackage package, bool silent, CancellationToken cancellationToken=default)
Asynchronously repair a package using winget.
bool UninstallPackage(WinGetPackage package)
Uninstall a package using winget.
List< WinGetPackage > SearchPackage(string packageId, string sourceName, bool exact=false)
Uses the winget search function to search for a package that maches the given name.
List< WinGetPackage > GetInstalledPackages()
Gets a list of all installed packages.
bool PinAdd(WinGetPackage package, bool blocking=false)
Adds a pinned package to winget.
bool ImportPackagesFromFile(string file)
Imports packages and trys to installes/upgrade all pakages in the list, if possible.
async Task< bool > PinRemoveAsync(WinGetPackage package, CancellationToken cancellationToken=default)
Asynchronously removes a pinned package from winget.
bool Download(WinGetPackage package, string directory)
Downloads the installer of a package using winget.
bool RepairPackage(WinGetPackage package, bool silent)
Repairs a package using winget.
async Task< bool > UpgradeAllPackagesAsync(CancellationToken cancellationToken=default)
Asynchronously tries to upgrade all packages using winget.
async Task< bool > ImportPackagesFromFileAsync(string file, CancellationToken cancellationToken=default)
Asynchronously imports packages and trys to installes/upgrade all pakages in the list,...
bool UpgradeAllPackages(bool silent)
Tries to upgrade all packages using winget.
async Task< string > HashAsync(FileInfo file, CancellationToken cancellationToken=default)
Asynchronously executes the WinGet hash function, to calculate the hash for the given file.
bool RepairPackage(string packageId, bool silent)
Repairs a package using winget.
bool PinRemoveInstalled(WinGetPackage package)
Removes a pinned package from winget.
async Task< bool > PinAddAsync(WinGetPackage package, string version, CancellationToken cancellationToken=default)
Asynchronously adds a pinned package to winget.
async Task< List< WinGetPackage > > GetInstalledPackagesAsync(string packageId, bool exact=false, CancellationToken cancellationToken=default)
Asynchronously gets a list of all installed packages. That match the provided name.
WinGetPackage? GetExactInstalledPackage(string packageId, string sourceName)
Gets a installed package, that matchs the provided id/name. If there are multiple matches,...
async Task< bool > UninstallPackageAsync(WinGetPackage package, bool silent, CancellationToken cancellationToken=default)
Asynchronously uninstall a package using winget.
bool PinAddInstalled(string packageId, bool blocking=false)
Adds a pinned installed package to winget.
WinGetPackageManager()
Initializes a new instance of the WGetNET.WinGetPackageManager class.
bool UpgradePackage(WinGetPackage package, bool silent)
Upgrades a package using winget.
WinGetPackage? GetExactInstalledPackage(string packageId)
Gets a installed package, that matchs the provided id/name. If there are multiple matches,...
bool PinAddInstalled(string packageId, string version)
Adds a pinned installed package to winget.
bool PinAddInstalled(WinGetPackage package, string version)
Adds a pinned installed package to winget.
async Task< List< WinGetPinnedPackage > > GetPinnedPackagesAsync(CancellationToken cancellationToken=default)
Asynchronously gets a list of all pinned packages.
bool PinAdd(string packageId, string version)
Adds a pinned package to winget.
async Task< bool > DownloadAsync(string packageId, DirectoryInfo directory, CancellationToken cancellationToken=default)
Asynchronously downloads the installer of a package using winget.
bool PinAdd(string packageId, bool blocking=false)
Adds a pinned package to winget.
async Task< bool > InstallPackageAsync(WinGetPackage package, bool silent, CancellationToken cancellationToken=default)
Asynchronously install a package using winget.
List< WinGetPackage > SearchPackage(string packageId, bool exact=false)
Uses the winget search function to search for a package that maches the given name.
List< WinGetPackage > GetUpgradeablePackages()
Get all upgradeable packages.
bool InstallPackage(WinGetPackage package)
Install a package using winget.
string Hash(string file)
Executes the WinGet hash function, to calculate the hash for the given file.
async Task< string > HashAsync(string file, CancellationToken cancellationToken=default)
Asynchronously executes the WinGet hash function, to calculate the hash for the given file.
bool UpgradePackage(string packageId, bool silent)
Upgrades a package using winget.
bool Download(string packageId, DirectoryInfo directory)
Downloads the installer of a package using winget.
async Task< bool > UninstallPackageAsync(string packageId, CancellationToken cancellationToken=default)
Asynchronously uninsatll a package using winget.
bool PinAdd(WinGetPackage package, string version)
Adds a pinned package to winget.
Represents a winget arguments string for different winget actions.
WinGetArguments All()
Adds the '–all' flag to the arguments.
WinGetArguments Blocking()
Adds the '–blocking' flag to the arguments.
WinGetArguments Installed()
Adds the '–installed' flag to the arguments.
static WinGetArguments PinAdd()
Creates a new winget arguments object with "pin add" as the base cmd.
WinGetArguments Force()
Adds the '–force' flag to the arguments.
WinGetArguments Silent()
Adds the '–silent' flag to the arguments.
static WinGetArguments List()
Creates a new winget arguments object with "list" as the base cmd.
WinGetArguments IncludeUnknown()
Adds the '–include-unknown' flag to the arguments.
static WinGetArguments PinList()
Creates a new winget arguments object with "pin list" as the base cmd.
static WinGetArguments Search()
Creates a new winget arguments object with "search" as the base cmd.
WinGetArguments Query(string query)
Adds a query to the arguments.
WinGetArguments AcceptSourceAgreements()
Adds the '–accept-source-agreements' flag to the arguments.
WinGetArguments AcceptPackageAgreements()
Adds the '–accept-package-agreements' flag to the arguments.
WinGetArguments Source(string source)
Adds a source query to the arguments.
WinGetArguments Exact()
Adds the '–exact' flag to the arguments.
static WinGetArguments PinRemove()
Creates a new winget arguments object with "pin remove" as the base cmd.
WinGetArguments File(string file)
Adds a file path to the arguments.
static WinGetArguments Repair()
Creates a new winget arguments object with "repair" as the base cmd.
static WinGetArguments Hash()
Creates a new winget arguments object with "hash" as the base cmd.
static WinGetArguments Uninstall()
Creates a new winget arguments object with "uninstall" as the base cmd.
static WinGetArguments Export()
Creates a new winget arguments object with "export" as the base cmd.
static WinGetArguments Upgrade()
Creates a new winget arguments object with "upgrade" as the base cmd.
static WinGetArguments PinReset()
Creates a new winget arguments object with "pin reset" as the base cmd.
static WinGetArguments Install()
Creates a new winget arguments object with "install" as the base cmd.
WinGetArguments Version(string version)
Adds a version query to the arguments.
Represents a winget package.
string Id
Gets the id of the package.
string Name
Gets the name of the package.
bool HasShortenedId
Gets if id of the package is shortened.
bool HasNoId
Gets if the package does not provide an id.
Exception that gets thrown if a winget feature is not supportet in the installed winget version.