📅 March 15, 2023

winget - The Windows Package Manager

Ever since my early days of using a computer, I've always found enjoyment in installing programs on a fresh OS install. I enjoyed it. Combining various software applications in a way that was tailored to me provided joy. As I've grown older, I have found that my Windows desktop applications I use have been relatively static. I occasionally find something new, but I have used the majority of my apps for a long time. An unchanging list of applications is ripe for automating installation. This is where winget comes in. winget is an out-of-the-box command line tool that enables users to discover, install, upgrade, remove, and configure applications on Windows 10 machines and newer.

My main use case for using winget is to have a quick and easy way to install my collection of Windows apps whenever I get a new PC, or after reinstalling Windows. With that in mind, I am not going to review the discovery, upgrade, and removal features of winget.

winget export

The winget export command will export a JSON file of apps. The resulting file can be used with the winget import command to automate the installation of multiple applications.

If you have access to the PC with your apps currently installed, a convenient way to generate the JSON file is with a tool called WingetUI. WingetUI provides a nice GUI for running winget commands.

WingetUI

Another tool for generating the JSON file is winstall. winstall is a web app that allows you to browse and select apps to create the JSON file needed to perform a winget import command.

winstall

winget import

The winget import command can automatically install multiple apps specified in a JSON file, which can be generated using the tools discussed above. A sample winget import command is below:

winget import -i C:\Users\ryan\Desktop\my-winget-packages.json

and a sample winget JSON file is below

{
    "$schema": "https://aka.ms/winget-packages.schema.2.0.json",
    "CreationDate": "2022-08-16T20:55:44.415-00:00",
    "Sources": [{
        "Packages": [
            {
                "PackageIdentifier": "Git.Git"
            },
            {
                "PackageIdentifier": "Google.Chrome"
            },
            {
                "PackageIdentifier": "Mozilla.Firefox"
            }
        ],
        "SourceDetails": {
            "Argument": "https://cdn.winget.microsoft.com/cache",
            "Identifier": "Microsoft.Winget.Source_8wekyb3d8bbwe",
            "Name": "winget",
            "Type": "Microsoft.PreIndexed.Package"
        }
    }],
    "WinGetVersion": "1.4.2161-preview"
}

Running winget import with that JSON file would install Git, Chrome, and Firefox.

Try it!

The next time you need to install a batch of applications give winget a try! It doesn't take a long time to get started and the winget CLI is available out of the box.

# random | technology