winget-cli
winget-cli copied to clipboard
Enable winget to upgrade itself
Description of the new feature/enhancement
Winget cannot update it's own package currently, due to the following sequence:
- winget begins deployment of its package
- Windows deployment for MSIX needs all processes for the package to be shut down
- Deployment sends a CTRL-C message to processes with no active windows
- winget responds to CTRL-C message with cancellation of the deployment operation
So a whole lot of nothing happens.
Proposed technical implementation details
The most straightforward way is probably to special case this scenario. We could also do some work to run afterward to report the result. For instance (install or update eventually):
winget install winget
... all boilerplate until install progress ...
winget needs to terminate in order to update itself, see you in a bit.
Once completed, a new (cmd, unless you can somehow set the default subsystem CONSOLE handler) window comes up to automatically run:
winget post-self-update
Success, winget has been updated to v0.1.99999
Press enter to close this window
or
winget post-self-update
winget update failed: Some perfectly valid reason I'm sure.
winget is still running v0.1.12345
Press enter to close this window
Given that winget will be part of the App Installer bundle, pre-installed and updated over the Windows Store AND that winget also plans support for Windows Store applications... is this issue in the current form still relevant?
@Croydon, there are several different scenarios at play when we take into account enterprise Group Policy, and private sources. Some systems may have the Microsoft Store disabled, and they may be on their own private networks. It would still be possible to pull in a copy of the App Installer and provide it via a private REST source.
When winget is available as a built in then "winget upgrade winget" should switch me over from the manually installed appxbundle to the officially supported version from windows.
@lovettchris you should automatically get updates from the Microsoft Store since the releases here are signed. The store would only hand you the "latest" version available for the environment (Windows Insider) or Flight (Partner Center Concept). Once a newer version is published, you would get that update to App Installer.
The ability to use the Windows Package Manager to upgrade itself is not necessary to receive the latest stable version from the Microsoft Store. The only requirement is the version in the store must be higher than the version one has installed.
It is now possible to use the Windows Package Manager to install via the "msstore" source.
winget install "App Installer" -s msstore --force
edited: I added "--force" as this is required in some scenarios.
We still have work with the "msstore" source to report the version in the REST endpoint. We also have work to include monikers in the "msstore" source so the command could be winget install winget -s msstore.
@denelon could you explain it a bit for an "end-user": is it correct that:
winget install "App Installer" -s msstoresupposed to update App Installer- winget is a part of App Installer
- hence
winget install "App Installer" -s msstoreis supposed to update winget ..in certain case
?
What are those cases and is it safe to just try winget install "App Installer" -s msstore and see what happens?
@YakovL
- Technically it's just asking the Windows Package Manager to install the App Installer.
- The Windows Package Manager is distributed with the App Installer.
- True
The install command today does not perform validation if a package is already installed. We're likely to start checking to see if a package is already installed so a user can get the correct upgrade behavior for packages that require certain switches to be passed to the installer for the upgrade scenario to function correctly (Visual Studio is an example of this). In the future, we may add a repair option for MSIX packages, and with the switch to the "upgrade" behavior, you could still pass "--force" to insist the Windows Package Manager perform the install action "winget install "App Installer" -s msstore --force`.
Yes, you are likely to be prompted about which version of App Installer you are attempting to install, and you will be informed if the version you are about to install is "older" than the one present on your system.
Does this work? because I tried and winget just spins on "Starting package install..." forever.
winget v1.3.2691 windows 21h2
@santagada is a bad user experience, but yes it will work.
Depending on the version difference, I've seen it hang in the progress bar, and I've seen it throw an exception. Generally, if I wait a few seconds after that point, I can either [ctrl]+[c] or restart my terminal and run winget -v to see if the new version is installed.
winget install winget --accept-source-agreements --accept-package-agreements --force
winget -v v1.4.10173
winget upgrade -all winget upgrade -all -silent
Having to kill the application after a while is really bad for automation. Winget is supposed to be used for automation right? I ask because not having it on server versions kinda confuses me a bit.
There are very few things you can do when you are trying to use the tool....to update the thing you are using. Especially since this is a package and not a traditional app
I found a better way to resolve this, install scoop first, then use scoop to install/update winget. As winget is just an installer, not a package manager.
The App Installer was just added to the community repository so you can now run winget upgrade winget.
The App Installer was just added to the community repository so you can now run
winget upgrade winget.
But the previous version cannot be removed, because it's a part of windows.
tried winget upgrade winget, got ~"No available updates found. No more recent versions in the configured sources." (translated back to English, so the wording may be not accurate) winget -v → v1.6.3133
The App Installer was just added to the community repository so you can now run
winget upgrade winget.But the previous version cannot be removed, because it's a part of windows.
Yes.....your point is? There isn't any way around that, it happens no matter how you update winget or any in-box app. Its just how Windows handles it.