A closer look at Windows PowerShell OneGet - Part 1

On Thursday, Distinguished Engineer Jeffrey Snover announced the availability of the Windows Management Framework 5.0 Preview. In tow was Windows PowerShell OneGet, touted as the new way to discover and install software on Windows. But after digging deeper into the preview bits, it’s clear OneGet is much more than a collection of cmdlets.

Let’s take a closer look.


Windows PowerShell OneGet is a bit of a misnomer -- it isn't strictly tied to PowerShell. Instead, OneGet represents a framework of hosts, providers and packages with a core set of APIs at its center. Peeking behind the curtains, we have three main component areas:

The OneGet core API houses all the package discoverability and installation support goop that powers OneGet hosts and providers. Specifically goop in areas such as asynchrony and operating system integration.

OneGet hosts tap into the core API. Typically, their job is to bridge the divide between the user and the API. Windows PowerShell, for example, exposes core functionality by way of handy cmdlets.

Requests from these hosts are relayed by the core to OneGet providers that are responsible for processing requests. The Chocolatey provider, for example, may receive a request for a package it does not have in its local cache. It will hold onto that request and retrieve the information it needs from its Internet-based package repository before responding.

To make that clearer, we'll walk through a simple PowerShell example.

  1. A script or user imports the Windows PowerShell OneGet module, tapping into the OneGet Core API. Install-Package is invoked to find and install the Notepad2 package.
  2. The Windows PowerShell host (hosting the OneGet module) makes a "find package" request via the OneGet Core API.
  3. The OneGet Core API locates a provider able to handle the request and passes it on.
  4. The provider, Chocolatey in this case, receives the request and scurries about, looking for the Notepad2 package. It downloads it from the central Chocolatey repository and proceeds to install it, providing progress and other information along the way. If all goes well, Notepad2 is now installed.

In Part 2, we'll take a closer look at how providers are implemented and try to hack one together.