Poushec.UpdateCatalogParser 4.2.0

dotnet add package Poushec.UpdateCatalogParser --version 4.2.0
                    
NuGet\Install-Package Poushec.UpdateCatalogParser -Version 4.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Poushec.UpdateCatalogParser" Version="4.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Poushec.UpdateCatalogParser" Version="4.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Poushec.UpdateCatalogParser" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Poushec.UpdateCatalogParser --version 4.2.0
                    
#r "nuget: Poushec.UpdateCatalogParser, 4.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Poushec.UpdateCatalogParser@4.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Poushec.UpdateCatalogParser&version=4.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Poushec.UpdateCatalogParser&version=4.2.0
                    
Install as a Cake Tool

Update Catalog Parser

This library was made to help me or anyone else to collect data from https://www.catalog.update.microsoft.com/ in a comfortable way.

Credits

Big thanks to ryan-jan (https://github.com/ryan-jan) for his MSCatalog PowerShell module. My original plan was to re-write this module as C# class library.)

Other implementations

How to use it

Instantiate the CatalogClient first:

CatalogClient catalogClient = new CatalogClient(new HttpClient(), pageReloadAttemptsAllowed = 3);

(Optional) If you want CatalogClient to use a particular instance of HttpClient you can pass it as a first argument to the constructor. If you will not provide it - it will be created for you.

(Optional) Use the pageReloadAttemptsAllowed argument to set the number of page refresh attempts allowed. Catalog can be unreliable at times and you almost certain to get at least one invalid page from it when working with a lot of search results. Default value: 3

List<CatalogSearchResult> searchResults = await catalogClient.SendSearchQueryAsync("SQL Server 2019", ignoreDuplicates = true);

This method will load and parse all available search result pages and return you a collection of CatalogSearchResult objects. Each of this objects represent search result from catalog.update.microsoft.com with data available through search results page only:

  1. Update's ID
  2. Title
  3. Products
  4. Classification
  5. Last Updated date
  6. Version
  7. Size
  8. Size in bytes

(Optional) If ignoreDuplicates argument is TRUE than function will return only updates with unique Title and SizeInBytes fields. Default: TRUE

If you're only interested in results from a first page (or just how many results there are) use this method instead:

CatalogResponse firstResultsPage = await catalogClient.GetFirstPageFromSearchQueryAsync("SQL Server 2019");

This method returns a CatalogResponse object representing the current search results page, specifically:

  1. Collection of CatalogSearchResult objects which holds search results from current page (SearchResults)
  2. Total search query results count (ResultsCount)
  3. The field indicating if it is a final page (FinalPage)

Both of these methods has optional arguments sortBy and sortDirection. Use them if you want Catalog to sort your query results.

To get more info on a particular update (which you would normally get by following the link on the results list) pass one of the CatalogSearchResult objects you've got from SendSearchQueryAsync to this method:

UpdateInfo updateDetails = await catalogClient.GetUpdateDetailsAsync(CatalogSearchResult searchResult)

It will get you an instance of UpdateInfo class with all the collected details from the details and download pages, for example download links, HardwareIDs if it is a driver, Supersedes list if it is an Update etc.

Example Usage

Get all available results from a search query:

using Poushec.UpdateCatalogParser;

var client = new HttpClient();
var catalogClient = new CatalogClient(client);

var testSearchResults = await catalogClient.SendSearchQueryAsync("SQL Server 2022");
            
Console.WriteLine($"{testSearchResults.Count} updates found\n");

testSearchResults.ForEach(result => Console.WriteLine($"{result.Title} ({result.LastUpdated.ToString("yyyy/MM/dd")})"));

Output:

5 updates found

SQL Server 2022 RTM Cumulative Update (CU) 4 KB5026717 (2023/05/11)
SQL Server 2022 RTM Cumulative Update (CU) 3 KB5024396 (2023/04/13)
SQL Server 2022 RTM Cumulative Update (CU) 2 KB5023127 (2023/03/23)
SQL Server 2022 RTM Cumulative Update (CU) 1 KB5022375 (2023/03/10)
Security Update for SQL Server 2022 RTM GDR (KB5021522) (2023/03/05)

Get the first results page and iterate through next:

using Poushec.UpdateCatalogParser;

var client = new HttpClient();
var catalogClient = new CatalogClient(client);

var currentResultsPage = await catalogClient.GetFirstPageFromSearchQueryAsync("SQL Server 2016");
var allSearchResults = currentResultsPage.SearchResults;

Console.WriteLine($"{currentResultsPage.ResultsCount} updates found\n");
Console.WriteLine($"Results on current page: {currentResultsPage.SearchResults.Count}");

while (!currentResultsPage.FinalPage)
{
    currentResultsPage = await currentResultsPage.ParseNextPageAsync();
    allSearchResults.AddRange(currentResultsPage.SearchResults);

    Console.WriteLine($"Results on current page: {currentResultsPage.SearchResults.Count}");
}

Output:

79 updates found

Results on current page: 25
Results on current page: 25
Results on current page: 25
Results on current page: 4

Limitations

What this library does - is parse HTML pages from catalog.update.microsoft.com, so it derives it's limitations directly from it. For example, it cannot return more than 1000 search results from a single query.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.2.0 305 10/17/2025
4.1.0 244 4/30/2025
4.0.3 255 9/29/2024
4.0.2 179 9/27/2024
4.0.1 180 8/3/2024
3.0.0 214 6/16/2024
2.2.0 295 6/6/2023
2.1.1 255 5/31/2023
2.0.0 260 5/30/2023