Working With Winget Settings

June 28, 2023
9 min read

Taking fullest advantage of the built-in Windows package manager — namely, winget, which runs in both Windows PowerShell and in a Command Prompt session — requires interacting with the command’s internal settings. You can access these by editing the command’s associated settings.json file. This file typically resides in the folder that resolves from the following folder specification:

%LOCALAPPDATA%\Packages\Microsoft. DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings

That said, the easiest way to access it is by using winget settings directly from the command line.

Check Out the Other Winget Articles

This article is the third in a series about the winget package manager. For previous articles, see:

Other articles in this series address topics such as the following:

  • How to resolve multiple instances of the same app or application, some up-to-date and some not
  • Supplemental tools to check and manage Windows updates for which winget manifests and packages aren't available
  • Dealing with “pinned applications” in winget
  • Exploring the graphical WingetUI tool as a command-line alternative

Understanding JSON

In case you aren’t familiar with JSON, JSON stands for JavaScript Object Notation. It was developed in the early 2000s as a more compact alternative to XML. JSON is designed to be both easy for humans to read and understand, but also for computers to parse and ingest. It has largely succeeded in these aims and is much more widely used than XML for data exchange nowadays.

For a good place to start learning more about JSON and its syntax, I recommend Ben Lloyd Pearson’s Complete Guide to Working with JSON in the Nylas blog. It covers the motivation and history of JSON nicely, and includes a succinct and extremely helpful description of its syntax and structure. By itself, this reference should suffice to help you figure out how to interact with and edit winget’s settings.json file directly and correctly.

Accessing the settings.json File in Winget

You must download, install, and run the release preview version of winget to access its experimental features. Otherwise, they’re not available. As I write this story, the current production version of winget is v1.5.1572, while the current preview version (as of June 2023) is v1.6.1573. That preview version can be hard to find at GitHub, where Microsoft maintains winget (Microsoft team lead Demetrius Nelon recommends https://t.co/CT0OSmXCYt).

You can always check experimental features in any winget version by using the winget features command. Figures 1 and 2 show the different outputs you’ll see from the current production (Figure 1) and preview (Figure 2) versions. In the production version, you will see the following message:

This is a stable release of the Windows Package Manager. If you would like to try experimental features, please install a pre-release build. Instructions are available on GitHub at https://github.com/microsoft/winget-cli.

In the “stable release” of Winget, it shows no experimental features.
Figure 1: In the production version, winget features lets you switch to the preview. | Used with permission from Microsoft. View Full Size
This screenshot shows that only the preview version shows info about experimental features both enabled and disabled.
Figure 2: In the preview version, the upper pane shows the version number; the lower pane shows that package pinning and direct MSI installation are enabled. | Used with permission from Microsoft. View Full Size

Before I describe how to turn on the various experimental settings that are shown in Figure 2, I’ll take a brief detour to introduce the best tool for editing winget’s settings.json file.

The Best settings.json Editing Tool

You can use any text editor to work with settings.json. I strongly recommend Don Ho’s excellent and capable Notepad++ text editor. It’s free — donation-ware, actually — and  it provides line and column numbers as part of its intrinsic user interface (UI). Because winget’s error messages for settings.json reference both line and column numbers, it’s my tool of choice for editing such files. I’ve been happily using this tool since the late 1990s or early 2000s. Visit the Notepad++ Download page to grab yourself a copy, if you don’t have one already.

Enabling Winget Experimental Settings

The first time you enter winget settings at the command line in PowerShell or Command Prompt, Windows prompts you as to which application to use. Unless it’s already your default text editing program, you’ll have to “Select an app” (first interior pane), and then navigate to the .exe file for notepad++ (second interior pane fragment), as shown in Figure 3. Choose Always to keep it set that way.

When you access for the first time, settings.JSON asks which editor it should use.
Figure 3: The command winget settings prompts for an editing app to use upon first invocation. | Used with permission from Microsoft. View Full Size

After you choose which editor to use, you can turn on all experimental settings. Here are the contents of the settings.json file with all current experimental settings enabled. To use one or more of these items, feel free to copy-and-paste into your own settings.json file.

{
"$schema": "https://aka.ms/winget-settings.schema.json",
"visual": {
"progressBar": "rainbow"
},
"experimentalFeatures": {
"dependencies": true,
"directMSI": true,
"pinning": true,
"uninstallPreviousArgument": true,
"configuration": true,
"windowsFeature": true,},
}

As you can see in Figure 4, after saving settings.json, closing and re-opening Windows Terminal, and then running winget features, all experimental features show Enabled under the Status column.

Enabling Winget experimental features hinges on each feature’s Property name.
Figure 4: The key to enabling winget experimental features is to use the “Property” name shown in the Property column. | Used with permission from Microsoft. View Full Size

Understanding Winget Experimental Features

Once you’ve turned an experimental feature on, you can use the syntax winget <property> -? to view its associated help information. Figure 5 shows the help info for the winget pin command. You can use this command to limit the scope of winget upgrade (or block it completely). I first encountered this capability in connection with Discord, on a third-party test machine with this feature enabled without my knowledge. Figuring this out has been a real adventure, in fact. (For more details, see the “Case in Point…" section below.)

This screenshot shows help info for winget pin.
Figure 5: The help info for winget pin. | Used with permission from Microsoft. View Full Size

The help text for winget pin reads as follows (quoted verbatim):

Manage package pins with the sub-commands. A pin can limit the Windows Package Manager from upgrading a package to specific ranges of versions, or it can prevent it from upgrading the package altogether. A pinned package may still upgrade on its own and be upgraded from outside the Windows Package Manager.

usage: winget pin [<command>] [<options>]
The following sub-commands are available:
add Add a new pin
remove Remove a package pin
list List current pins
reset Reset pins
For more details on a specific command, pass it the help argument. [-?]

Essentially, winget pin excludes specific packages from the blanket upgrade commands (for example, winget upgrade –all and winget upgrade –all –include-unknown). For applications that require specific versions (or specific tooling via runtime executables), it can be very handy.

Of all the other features enabled in winget, only configure also shows up at the command line. (All the others affect its runtime behavior, but don’t affect its command terms, syntax, or capabilities.) The help text for configure reads as follows (also appears in Figure 6):

Ensures that the system matches the desired state as described by the provided configuration. May download/execute processors in order to achieve the desired state. The configuration and the processors should be checked to ensure that they are trustworthy before applying them.

To produce configure help, type winget configure –help at the command line.
Figure 6: Help text for winget configure references its capabilities and sub-commands, with some interesting options. | Used with permission from Microsoft. View Full Size

The basic impetus for the configure command is to enable winget users to match a targeted configuration, as specified in a supplied configuration file, through a corresponding sequence of updates and installs. (See this GitHub discussion for information about the layout and contents of such files, and more. Here’s a download link for the configuration file for the recently introduced Dev Home Preview app.) Please test and validate such files before putting them into production (using the test and validate sub-commands).

Case in Point: Discord.Discord

After I enabled the experimental package pinning capability on several of my PCs (mostly test machines, but also one “road laptop” I use when I travel), I observed that Discord pins itself to whatever version is current. I show that condition in Figure 7, after running winget upgrade –all –include-unknown. Notice that Discord does not get updated.

Although the word “pinned” does not appear anywhere, “explicit targeting” tells you Discord is pinned.
Figure 7: When winget refers to “explicit targeting,” that means the app or application version is pinned. | Used with permission from Microsoft. View Full Size

Interestingly, my attempt to upgrade Discord by targeting version 1.0.9013 reported success, as shown in Figure 8. That text reads “Successfully installed” at the conclusion of the upgrade operation.

Sometimes, even when winget reports success, it actually fails. This is a case in point.
Figure 8: A targeted winget upgrade reports success, but.... | Used with permission from Microsoft. View Full Size

Even so, this still left the old version (1.0.9012) behind. As you can see in Figure 9, a quick hop into Settings > Apps > Installed apps still shows version 1.0.9012 as installed.

The Installed apps info in Settings shows version 1.0.9012 as installed.
Figure 9: Inside Settings > Apps > Installed apps, version 1.0.9012 still shows as current. 
| Used with permission from Microsoft. View Full Size

I wasn’t able to clear the winget upgrade alert until I uninstalled version 1.0.9012, and then ran winget install Discord.Discord to bring version 1.0.9013 into the picture. Figure 10 shows the results of a subsequent winget upgrade operation that shows no more pending updates. That’s what “No installed package matching input criteria” means in this case.

When winget reports “No installed package found matching input criteria,” that means it finds no new updates are needed.
Figure 10: “No installed package…” means winget finds nothing that needs an upgrade. | Used with permission from Microsoft. View Full Size

Things don’t always go exactly as expected with winget but, as with this Discord illustration, you can nearly always get things working properly by hook or by crook.

Should You Enable Winget Experimental Features?

What makes winget features experimental is that the developers are trying them out. In other words, they’re not completely finished, nor completely ready for prime-time production use just yet. Thus, I’d recommend enabling and using such features for learning and observation of what winget may be able to do someday. You can make your own call on pinning and configuration items. These are the most likely to be of use in production environments anyway.

Ed Tittel

Ed Tittel

Ed Tittel is a long-time computing industry writer, consultant, and occasional expert witness. He’s the author of over 100 computer trade books, countless articles, and other stuff. For more info, please visit https://edtittel.com.