WinGet configuration Preview
The Windows Package Manager team has been working on several things we’re sure you will be very excited about.
If you’ve been following the WinGet blogs, you’re already familiar with package management on Windows. We’ve got some goodies in store for you like package pinning, our new PowerShell module, and running WinGet in the system context. We’ve gotten lots of feedback on how WinGet has been a game changer in terms of time saved, convenience, and simplification when setting up a new Windows PC. WinGet configuration takes things to the next level!
Save time and skip the manual effort of setting up a new machine or onboarding a new project by using this unattended, reliable, and repeatable mechanism.
Remove the worry of searching for the right version of software, packages, tools and frameworks to download or settings to apply. WinGet configuration reduces this manual and error-prone process down to a single command with a WinGet configuration file. Just run
winget configure <WinGet configuration file> in the command prompt and when it’s done, you are ready to code!
WinGet configuration was built on top of PowerShell DSC. It’s using a declarative YAML file that describes what the environment “looks like” when it’s configured. The file defines the environment in terms of DSC resources that can test the current state of the system and apply the necessary changes.
If you want to try this with WinGet, you will need to install one of our preview releases and enable the experimental feature. Learn more about WinGet configuration at Microsoft Learn. You can also try this functionality out in Dev Home. We’ve provided several sample configurations in the Dev Home project at GitHub.
WinGet PowerShell modules
Many of you have been asking about when a native PowerShell module would be available for WinGet. The text-based output from WinGet isn’t easy to parse, and that makes it much harder to use in scripts. The first “prerelease” module was shipped near the end of April 2023, and we published an update on May 12th.
Note: The module is not listed as “Prelease”, but it should be treated as such. The version published on May 12th is 0.2.0 and the Microsoft.WinGet.DSC module depends on Microsoft.WinGet.Client so it couldn’t be published as “Prerelease”. If you are comfortable with using a preview version:
Open up PowerShell (I like to use Windows Terminal and PowerShell 7) and run
The magic of WinGet configuration is powered by PowerShell DSC (Desired State Configuration). The Microsoft.WinGet.DSC module allows you to configure your WinGet settings and preferences. It also enables you to install WinGet packages using
We’re also working on Microsoft.WinGet.Source to manage WinGet REST sources, and Microsoft.WinGet.Create to generate manifests for packages. Once these have all been published to the PowerShell Gallery, we will wrap them up in the Microsoft.WinGet module so you get all the goodness with a single install.
Some of the cmdlets require PowerShell 7, but we’ve enabled enough functionality to allow you to use Windows PowerShell to install, repair, or upgrade WinGet so you can then
Install-WinGetPackage Microsoft.PowerShell and then take full advantage of WinGet configuration.
Sometimes you don’t want WinGet to upgrade certain applications. If you’ve ever run
winget upgrade --all and it upgraded something you didn’t want, you were forced to manually downgrade it afterwards. From that point on you have to remember this tedious process, or you gave up on the convenience of being able to use a single command. Packages may introduce breaking changes that you may not want to integrate into your workflow quite yet. Packages may update themselves and you prefer that experience. You may want to maintain some of the packages through other channels outside of WinGet, or you prefer one source over others within WinGet. You might also want some of the packages to stay in some major version but allow minor version changes during upgrade.
To achieve goals listed above, WinGet pinning supports three types of Package Pinning:
- Blocking: The package is blocked from
winget upgrade --allor
winget upgrade <WinGet package>, you will have to unblock the package to let WinGet perform an upgrade.
- Pinning: The package is excluded from
winget upgrade --allbut allows
winget upgrade <WinGet package>, a new argument “–include-pinned” will be introduced to let
winget upgrade --allinclude pinned packages.
- Gating: The package is pinned to specific version(s). For example, if a package is pinned to version 1.2.*, any version between 1.2.0 to 1.2.x is considered valid. To allow user override, “–force” can be used with
winget upgrade <WinGet package>to override some of the pinning created above.