basicx-StrgV/WGet.NET

How do you use this wrapper?

Closed this issue · 4 comments

maaa3 commented

I can't find any documentation or code examples, please tell me how to use this wrapper

Yes sorry, I haven't created proper documentation yet.


The namespace you need is WGetNET (using WGetNET;).
In this namespace you will find the three classes you can use to perform actions or get information with winget.

WinGetInfo:
The WinGetInfo class can be used to get information about winget itself.
If you want to check if winget is installed and what version is installed, this is the class you should use.

Checking if winget is installed could look like this:

WinGetInfo wingetInfo = new WinGetInfo();
if (wingetInfo.WinGetInstalled)
{
     Console.WriteLine("WinGet is installed.");
}
else
{
     Console.WriteLine("WinGet is NOT installed.");
}

WinGetPackageManager:
The WinGetPackageManager class is used for everything that has to do with packages.
If you want to install a package for example, you would use this class.

Ther code for installing a package could look like this:

WinGetPackageManager packageManager = new WinGetPackageManager();
packageManager.InstallPackage("Git.Git");

WinGetSourceManager:
The ‘WinGetPackageManager’ class is used for everything that has to do with sources.
If you want to add a source for example, you would use this class.

The code for adding a source could look like this:

WinGetSourceManager sourceManager = new WinGetSourceManager();
sourceManager.AddSource("msstore", "https://storeedgefd.dsx.mp.microsoft.com/v9.0", "Microsoft.Rest");

I hope this will help you getting started.
If you need any help with specific functions or if you have any other questions, I am happy to help.


I will try to add samples and documentation soon.

maaa3 commented

Thanks for the quick reply, how do i search using this wrapper?

Searching for packages can be done like this:

WinGetPackageManager packageManager = new WinGetPackageManager();
List<WinGetPackage> packages = packageManager.SearchPackage("Git");
maaa3 commented

Thank you!