microsoft / microsoft/winget-cli
📌 Pin a directory (exclude folder from upgrades)
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 26.4k
- Forks
- 1.8k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 15
Description
This proposal is an extension of Pin a package (#476) by @denelon.
Description of the new feature / enhancement
Users should be able to "pin" not only packages, but also directories (exclude folders from winget upgrade --all).
This can come in handy in many different scenarios, especially:
-
Preventing conflicts between multiple package managers (Scoop, Chocolatey, etc).
By pinningC:\chocoor%PROGRAMDATA%\scoopwinget upgrades will be disabled automagically for software installed through other means. -
Preventing accidental upgrades within development environments.
By pinningC:\Devdevelopers can install their tools safely and not worry about accidental upgrades from winget. Developers can even install multiple versions of same program using winget itself, without conflicts! -
Excluding entire game drives.
Games are installed and maintained through self-updating launchers (Steam, Epic, etc.). There are many reasons why users like to keep their game libraries, mods and launchers separate from the rest of their system. Those softwares are often installed on a dedicated game drive, physically separate from the rest of the system. Pinning a game drive, e.g.E:\will automatically exclude all games and related software from unwanted updates and potential conflicts, including all future installs.
Proposed technical implementation details
The list of pinned packages and directories should be included in settings.json and should support the usage of default environment variables (%PROGRAMDATA%\scoop, $Env:SYSTEMDRIVE\MyApps, etc.) — making it easy to edit, export and import configuration.
When upgrade or list command is initiatied, Winget can simply check the settings file and either perform or not perform an action on certain packages by matching their name and containing directory against the list in settings.json. This can easily be achieved by an IF/ELSE expression.
PROPOSED COMMANDS
winget pin --directory "C:\MyApps"should exclude all applications installed into C:\MyApps and all of its subfolders fromwinget upgrade --allcommand.winget unpin --directory "C:\MyApps"should unpin that directory, making all the applications installed into C:\MyApps and all of its subfolders upgradable usingwinget upgrade --allcommand.winget list --pinnedshould list all pinned directories, plus packages that have explicitly been pinned usingwinget pin <package>. It should not list packages that haven't explicitly been pinned usingwinget pin <package>.
Remarks
winget [un]pin <package>should have prevalence overwinget [un]pin --directory. Meaning that if an application has explicitly been (un)pinned usingwinget [un]pin <package>, it's pinned state should remain unchanged by pinning or unpinning it's containing directory.- If an application installed in a pinned directory is detected by
winget listcommand, a user should still be able to update that particular application usingwinget upgrade <package>explicitly.
EXAMPLE
- User installs VSCode in C:\MyApps\VSCode manually (not using Winget).
- User installs Firefox in C:\MyApps\Firefox using
winget install firefox --location "C:\MyApps\Firefox". winget upgrade --allupgrades both VSCode and Firefox.- User pins VSCode using
winget pin vscode. - User pins C:\MyApps using
winget pin --directory "C:\MyApps". winget list --pinnedlists:
C:\MyApps
Microsoft Visual Studio Codewinget upgrade --allupgrades neither VSCode nor Firefox.- User unpins C:\MyApps using
winget unpin --directory "C:\MyApps". winget list --pinnedlists:
Microsoft Visual Studio Codewinget upgrade --allupgrades only Firefox.winget upgrade vscodeupgrades VSCode.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing winget pin, unpin, list, and upgrade command entry points and how pinned packages are represented in settings.json. Define the directory-matching, environment-variable, precedence, and explicit-upgrade behavior, then add coverage showing that directory pins affect upgrade --all and list --pinned while explicit package pins remain effective.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100