Giter Site home page Giter Site logo

Comments (3)

github-actions avatar github-actions commented on September 22, 2024 1

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

from winget-cli.

marticliment avatar marticliment commented on September 22, 2024 1

As of version 1.8.1791, this code seems to be working. Thanks @PatrickSchmidtSE for pointing into the right direction

// var WinGetFactory = new WindowsPackageManagerElevatedFactory();
var WinGetFactory = new WindowsPackageManagerStandardFactory();
var WinGetManager = WinGetFactory.CreatePackageManager();

// CHANGE THIS INDEX
int selectedIndex = 0;

PackageCatalogReference installedSearchCatalogRef;
if (selectedIndex < 0)
{
    installedSearchCatalogRef = WinGetManager.GetLocalPackageCatalog(LocalPackageCatalog.InstalledPackages);
}
else
{
    PackageCatalogReference selectedRemoteCatalogRef = WinGetManager.GetPackageCatalogs().ToArray().ElementAt(selectedIndex);
    
    Console.WriteLine($"Searching on package catalog {selectedRemoteCatalogRef.Info.Name} ");
    CreateCompositePackageCatalogOptions createCompositePackageCatalogOptions = WinGetFactory.CreateCreateCompositePackageCatalogOptions();
    createCompositePackageCatalogOptions.Catalogs.Add(selectedRemoteCatalogRef);
    createCompositePackageCatalogOptions.CompositeSearchBehavior = CompositeSearchBehavior.LocalCatalogs;
    installedSearchCatalogRef = WinGetManager.CreateCompositePackageCatalog(createCompositePackageCatalogOptions);
}

var ConnectResult = installedSearchCatalogRef.Connect();
if (ConnectResult.Status != ConnectResultStatus.Ok)
{
    throw new Exception("WinGet: Failed to connect to local catalog.");
}

FindPackagesOptions findPackagesOptions = WinGetFactory.CreateFindPackagesOptions();
PackageMatchFilter filter = WinGetFactory.CreatePackageMatchFilter();
filter.Field = PackageMatchField.Id;
filter.Option = PackageFieldMatchOption.ContainsCaseInsensitive;
filter.Value = "";
findPackagesOptions.Filters.Add(filter);

var TaskResult = ConnectResult.PackageCatalog.FindPackages(findPackagesOptions);

Console.WriteLine("Begin enumeration");
foreach (var match in TaskResult.Matches.ToArray())
{
    if (match.CatalogPackage.DefaultInstallVersion != null)
        Console.WriteLine($"Package {match.CatalogPackage.Name} is available Online: " + match.CatalogPackage.DefaultInstallVersion.PackageCatalog.Info.Name);
    //else
        //Console.WriteLine("Package is local only: " + match.CatalogPackage.Id);
}
Console.WriteLine("End enumeration");

from winget-cli.

PatrickSchmidtSE avatar PatrickSchmidtSE commented on September 22, 2024

@marticliment if you debug, you will see the problem:

its not added to the composit catalog option sadly. BUT it is because you use "append" instead of "add". Add adds the catalog to the composite options. But i tested, does not change anything. Still i get packages shown which are not from the "winget" catalog , but have a empty source. We need a working --source winget option for the COM API
image

from winget-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.